Using Switch In Recyclerview Srcoll
I have use the Switch in the RecyclerView. It have facing the issue of recycling behaviour. When I switch on the 1st position ,it automatically on the switch at 10 postion ... I th
Solution 1:
You need to use this in the adapter:
@OverridepublicintgetItemViewType(int position) {
return position;
}
Solution 2:
This is a very common problem with RecyclerView
and there are lots of answers there in Stackoverflow.
You already have understood your problem i.e. reusing the views. So you might take a look at these answers to get a better idea about how you can overcome it.
- Put an else condition everywhere you need to update a view of a list item dynamically.
- Using another list to keep track of the list items in which the
Switch
is enabled or disabled. You can see this answer here.
These will do the trick for you I hope.
Post a Comment for "Using Switch In Recyclerview Srcoll"