I have a RecyclerView whose viewholder contains a button and a textview(Which contains the numberical value starting from 0). I want whenever that button is pressed, the value of the textview gets incremented. I tried using setTag() in onBindView but of no use. The value of the textview gets incremented in one or more viewholders with that approach. Please help!!
Asked
Active
Viewed 30 times
1 Answers
0
Somehow I managed to achieve the same myself. It is simple as there is no need for setTag() method anymore. Just take a map which stores the key(getAdpaterPosition()) and the value of the textView. When the button is pressed, increment the value of the textview in the map corresponding to the key(position). In the onBindViewHolder(), take the position argument and get value for the corresponding position from the map and set it in the textview. If the key exists in the map, get the value else get default value(0 in my case). In case, one doesnt understand let me know I will submit code here as well.Thanks.

Raghav Sharma
- 780
- 10
- 18