In my RecyclerViewAdapter
, I would like to know if this item is the last. How can I check it?
The onBindViewHolder
only has the position value
@Override
public void onBindViewHolder(UserViewHolder userViewHolder, int position) {
//DO SOMETHING TO THE VIEW IF THIS IS THE LAST ITEM IN RECYCLERVIEW
}
Once the recyclerview is idle, use the findLastVisibleItemPosition or findLastCompletelyVisibleItemPosition functions provided by the LinearLayoutManager or GridLayoutManager to get the last position.
RecyclerView provides these built-in layout managers: LinearLayoutManager shows items in a vertical or horizontal scrolling list. GridLayoutManager shows items in a grid. StaggeredGridLayoutManager shows items in a staggered grid.
What does notifyDataSetChanged() do on recyclerview ? Notify any registered observers that the data set has changed. There are two different classes of data change events, item changes and structural changes. Item changes are when a single item has its data updated but no positional changes have occurred.
setHasFixedSize(true) means the RecyclerView has children (items) that has fixed width and height.
simply you can do this:
if(position == myList.size()-1){/*lastItem*/}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With