Is there any way to get an item of the RecyclerView at a particular position outside the adapter. e.g in ListView we could do:
listView.getItem(position);
Can we do this with RecyclerView ? and also is the order of provided data list maintained ?
You can add your own method to RecyclerView
or I would suggest the RecyclerView.Adapter
itself.
For instance, for ListView, you have:
@Override
public Object getItem(int position) {
return listData.get(position);
}
You can add the same thing to your RecylcerView.Adapter
or access it another way by adding a simple method to your RecylcerView.Adapter
:
public List<Model> getList() {
return this.mModel;
}
Use it like this:
recyclerView.getAdapter().getList().get(position)
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