1

In my main layout I got Multiple recyclerViews with other views. While I used listView or GridView it was easier to maintain which view to focus next. But in case of RecyclerView how can we achieve that?

How can I request next focus to a child of recycler view from a child at different RecyclerView?

Suppose current focus is on 5th child of first recyclerView. Now we need to focus on 10th child of another recyclerView.

A_rmas
  • 784
  • 2
  • 10
  • 26
  • 1
    you can do this using interface.. `notifyItemChanged(10th position);` of recyclerView 2 – Santanu Sur Feb 23 '18 at 08:16
  • can you please give some snippet? – A_rmas Feb 23 '18 at 08:25
  • `recyclerview.smoothScrollToPosition(position)` is what you need – V-rund Puro-hit Feb 23 '18 at 08:26
  • 1
    @V-rundPuro-hit how is he going to focus or highlight that position just by scrolling to that position ? and also recyclerView 2 is in activity..how is going to access it from adapter? – Santanu Sur Feb 23 '18 at 08:28
  • @SantanuSur `smoothScrollToPosition` automatically focus particular item at the position specified. as long as focusing recyclerview we can always use `recyclerview.requestFocus()` – V-rund Puro-hit Feb 23 '18 at 08:33
  • 1
    @A_rmas you can use this link .. to check how to use interface.. to communicate with activity elements from adapter ... https://stackoverflow.com/questions/48904077/how-to-get-the-list-size-from-adapter-and-update-activity-ui-from-recycler-ada/48904196#48904196 and also you can use your interface method to highlight that particular position like `interfaceMethodHightlight(position) { mList.get(position).color(Color.Highlighted); rv_2.smoothScrollToPosition(position); mAdapter.notifyItemChanged(position);` – Santanu Sur Feb 23 '18 at 08:53
  • 1
    @SantanuSur thanks Taking it as a reference – A_rmas Feb 23 '18 at 09:44

0 Answers0