I have a RecyclerView in which a selected number of items show a different background color.
It gave me with many views with different color.
I used the position of adapter to change color and later I found that position changes when scrolling.
So I gave a unique code to every object of the ArrayList. And I gave the program to change background color if the unique code matches the given code.
Like,
uniqueCode = 5;
public void onBindViewHolder(//..){
Object object = objectArrayList.get(i);
if(object.uniqueCode() == uniqueCode ){
holder.layout.setBackgroundColor(//....);
}
}
But still I get some views changes the background color on scrolling which does not match that unique Id.
What is the solution to this problem ?