Groupie: Scroll to a certain Item in RecyclerView

Created on 8 May 2018  路  3Comments  路  Source: lisawray/groupie

By following your example, I managed to create some expandable list, using RowHeader extends ExpandableItem and RowItem extends Item.

I am using Section to wrap every ExpandableGroup(RowHeader)

Let's say I have all references of the header in a Map, and I want to be able to scroll the recyclerView to a particular RowHeader.

My questions:

  1. Is it better to store the ExpandableGroup or the RowHeader reference in the map?
  2. How to scroll the RecyclerView to a particular RowHeader?

Most helpful comment

You can hold a reference to either -- whatever you prefer!

If you hold a reference to the group, you can call:

val position = GroupAdapter.getAdapterPosition(group)

If you hold a reference to the header, you can call

val position = GroupAdapter.getAdapterPosition(item)

In either case, you can just use the position to scroll:

RecyclerView.smoothScrollToPosition(position)

All 3 comments

You can hold a reference to either -- whatever you prefer!

If you hold a reference to the group, you can call:

val position = GroupAdapter.getAdapterPosition(group)

If you hold a reference to the header, you can call

val position = GroupAdapter.getAdapterPosition(item)

In either case, you can just use the position to scroll:

RecyclerView.smoothScrollToPosition(position)

@lisawray can you help me on how to get the reference of the group ,I am facing some difficulties.

You need to scroll to the position of the item 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vahids28 picture vahids28  路  4Comments

forntoh picture forntoh  路  3Comments

ovitrif picture ovitrif  路  5Comments

punitda picture punitda  路  3Comments

ValCanBuild picture ValCanBuild  路  6Comments