'call get Adapter Position error in Android Studio
enter image description hereso, when I write position on 43rd line, int position on 40th line should change into final int position, but it doesn't. so I think I have to use getAdapterPosition() instead, inside bind view holder method. but I don't know how? can anyone help me? thanks in advance!
I tried to change int position into final int position manually let's say by myself tho didn't work.
Solution 1:[1]
Just call the getAdapterPosition() on your holder instead of the position and the lint should go away. Documentation states:
RecyclerView will not call this method again if the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the position parameter while acquiring the related data item inside this method and should not keep a copy of it. If you need the position of an item later on (e.g. in a click listener), use getAdapterPosition() which will have the updated adapter position.
Have a look here: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#onBindViewHolder%28VH,%20int%29
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tobi.g |
