0

I use FastAdapter for RecyclerView, let say originally it is like this (all items are collapsed, so only the first level items are showed):

  • Africa
  • Asia
  • Europe

When user expands position 1 it becomes:

  • Africa
  • Asia
    • Afghanistan
    • Burma
  • Europe

How do I get the 2nd position (Europe) when they are expanded like this? Using getItem(2) gives Afghanistan. Of course I can count manually because first level and second level uses different type in my case, but I am asking about the simplest way. Thanks in advance.

fikr4n
  • 3,250
  • 1
  • 25
  • 46

1 Answers1

0

The most simple solution would be to have a identifier per root element, and you then always access the element using that identifier this will eliminate the need of checking yourself where you find it.

public int getPosition(long identifier)

FastAdapter.getPosition

You can also use the method by passing in your item (it needs an Identifier)

mikepenz
  • 12,708
  • 14
  • 77
  • 117