In the case of a ListView
if we want to make a particular item selected we use the setSelection
method. How do we do this in case of RecyclerView
?
Simple answer: You should use RecyclerView in a situation where you want to show a lot of items, and the number of them is dynamic. ListView should only be used when the number of items is always the same and is limited to the screen size.
A ViewHolder describes an item view and metadata about its place within the RecyclerView. RecyclerView. Adapter implementations should subclass ViewHolder and add fields for caching potentially expensive View. findViewById(int) results.
Because the RecyclerView is much faster and more versatile with a much better API. Things like animating the addition or removal of items are already implemented in the RecyclerView without you having to do anything.
Use RecyclerView
LayoutManager
to scroll item at position
recyclerView.getLayoutManager().scrollToPosition(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