Comments (14)
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.
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.
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.
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.
Thanks @nitrico .. Also can you teel me that how can one setOnChildClickListener
for item using LastAdapter?
from lastadapter.
@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.
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.
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.
@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.
Thanks.. Will do it..
from lastadapter.
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.
Ok... tell me where and I will let u know If i find something..
from lastadapter.
Right here, for example, or by email [email protected] Thanks!
from lastadapter.
k.
from lastadapter.
Related Issues (20)
- First Item of recyclerview not clickable HOT 2
- Mixing version can lead to runtime crashes HOT 4
- How to use payloads refresh single item special element ?
- Changelog for version 2.3.0? HOT 3
- bind ViewModel is better than bind Model HOT 1
- How to Redraw/notifyDatachange when after property value change HOT 2
- How to use more <data></data> and more BR ? HOT 2
- Add the posibilitie to use RealmResult
- How listen item click listener HOT 2
- DataBinderMapperImpl not generated HOT 9
- Crash on LayoutHandler in kotlin HOT 1
- How to add item HOT 1
- AndroidX Support HOT 4
- kapt databinding error HOT 3
- Use DiffUtil to update list content HOT 2
- Support binding to LiveData (pass LifecycleOwner to items)
- Question: How to Set Single Selection Item? HOT 1
- Bind issues after Android Studio 3.2 release HOT 3
- PageableList
- Please move to mavenCentral (JCenter is closing down) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lastadapter.