Code Monkey home page Code Monkey logo

Comments (14)

nitrico avatar nitrico commented on August 10, 2024 1

Yes, you have to create a custom setter annotated with @BindingAdapter.

There is more information and an example with Picasso here: https://developer.android.com/topic/libraries/data-binding/index.html#custom_setters

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024 1

I understand that what you're trying to do is to set a click listener for specific views inside an item, is it right?

You can set it in the layout android:onClick="@{v -> item.onItemClick(v)}" and then implement that onItemClick(View view) method in the item type class.

Here's an example: #6 (comment)

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024 1

Do this instead

<data>
    <variable name="item" type="com.example.misc.Item" />
    <import type="com.example.misc.Listeners" />
</data>

and then use Listeners with capital 'L'

android:onClick="@{(theView) -> Listeners.onShareClickListener(item,theView)}"

Also, add the static keyword to the onShareClickListener method inside Listeners.

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024 1

I don't think you can use that library and LastAdapter at the same time, but you can try.

Adding "load more" functionality shouldn't be very complex, though. If you are using an ObservableList to keep your items, you only need to add more items to that list at the moment you reach the end of the list. You can use recyclerView.addOnScrollListener method to do it: http://stackoverflow.com/a/26643292

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

Thanks @nitrico .. Also can you teel me that how can one setOnChildClickListener for item using LastAdapter?

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

@nitrico Thanks but it is not working for me. I did

public void onShareClickListener(Item i,View view)
    {
        Toast.makeText(view.getContext(),"Share Clickedon:"+i.propertyText,Toast.LENGTH_SHORT).show();
    }

and in layout

android:onClick="@{(theView) -> listeners.onShareClickListener(item,theView)}"

and when I click it at runtime nothing happens.

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024

I think you mixed the two alternatives showed on the link.

There is one with the method implemented in the Item class (#6 (comment)) and another that implements the method statically in another class called Listeners (#6 (comment)).

If you are using the second one, make sure you import that Listeners class as it is done in the example.

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

I did ths

<variable
            name="listeners"
            type="com.example.misc.Listeners" />

if i do this <import type="...Listeners" />then it gives me dataBindng Error. saying cannot find the method onShareClick.. in the following class.. And I double checked both (the Class and the path) and their location is correct..

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

@nitrico thanks man.. You have been a great help... i was missing the static word in the method name..
Thanks.. and can you tell me if there is a way to add Load More Functionality to the RecyclerView keeping in check the LastAdapter? I came across BaseRecyclerViewAdapter and was wondering if it can be used together with LastAdapter.. because it has the LoadMore and other good options...

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

Thanks.. Will do it..

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024

You're welcome :)

I would also like to find a way to use those features while using LastAdapter, but didn't test them yet. So please let me know if you find something that works.

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

Ok... tell me where and I will let u know If i find something..

from lastadapter.

nitrico avatar nitrico commented on August 10, 2024

Right here, for example, or by email [email protected] Thanks!

from lastadapter.

syedalinaqi avatar syedalinaqi commented on August 10, 2024

k.

from lastadapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.