RecyclerView.ViewHolder – getLayoutPosition vs getAdapterPosition


Ask A Question





Login To post a question

Since the new support library version (22.x) the getPosition() method of the RecyclerView.ViewHolder class has been deprecated in lieu of the methods mentioned in the topic. I don’t really get the difference from reading the docs.
Could somebody explain the difference in layman’s terms?

I have the following use case – I give my adapter a List, and also want to be able to associate extra info for each list item. I have a position-to-extra mapping, and the mapping is available for the holders so that they can fetch the extra for their position and do stuff with it. In the holder, which method should I use?

What happens with the holder positions when list items at indices 0 and 1 are switched places? What do the methods return?

For more info please click herehttps://stackoverflow.com/q/29684154



Have a question or need a custom quote?
info@smartinfocare.com