I am trying to focus on a particular item of a recyclerview. What is the equivalent of the listview.setSelection(position)
when using a recyclerview.
You can manage and advance focus using keyboard arrows, reflecting this state visibly in the view item. Use can then press shift, then click another item with their mouse to select all items between the focused item and the clicked item. the position of the currently focused item, or RecyclerView#NO_POSITION if none.
To request focusing an item view, the view must be focusable and you call View. requestFocus() . If the view is not yet laid out at the time you want to focus it, you can call View. requestFocus() as soon as onViewAttachedToWindow() has been called.
You call RecyclerView.scrollToPosition(position)
to request the RecyclerView's LayoutManager to scroll to the given position during the next layout pass (it's asynchronous).
To request focusing an item view, the view must be focusable and you call View.requestFocus()
.
If the view is not yet laid out at the time you want to focus it, you can call View.requestFocus()
as soon as onViewAttachedToWindow()
has been called.
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