Rafael Muhamedzyanov Rafael Muhamedzyanov - 3 months ago 68
Android Question

How to get item from RecyclerView adapter in Android

In old code when I was using ListView with custom adapter I could get item with this code.

Message msg = (Message) adapter.getItem(poistion);


Now I am implementing RecyclerView. How can I get item from RecyclerView adapter?

Answer

You have to implement it yourself.

Add a new method in your custom Adapter and you are done.

public Message getItem(int position) {
  return messageList.get(position);
}
Comments