0

How to force adapter not use/repeat already inflated layouts, if the screen room is not enough to display all the items in listview, gridview or expandablelistview.

I have problem in expandablelistview, if I set background color of the selected item, another item`s background color is also changed(at first this item is not displayed on the screen, it appears after scroll).

So I conclude that second item is the same as the first.

  • 2
    The whole Idea of a listView / Recyclerview is to do exactly this .. – ligi Jul 15 '15 at 15:52
  • possible duplicate of [ListView reusing views when ... I don't want it to](http://stackoverflow.com/questions/6921462/listview-reusing-views-when-i-dont-want-it-to) – user1643723 Jul 15 '15 at 15:59

1 Answers1

1

In your adapter you should set the default background for all the items. And change this background only for the item(s) wanted.

something like:

holder.background.setBackground(defaultColor);
if (needTochange){
  holder.background.setBackground(newColor);
}
Chol
  • 2,097
  • 2
  • 16
  • 26