Posts

Showing posts with the label scroll

ListView/ExpandableListView randomly changes background colour on scroll/click/expand/collapse

Image
Working on the same android app which I posted about a couple of times earlier, I had this one feature I wanted to implement where I show a list of persons and highlight those from that list who have a birthday today. I tried a couple of different approaches to to the "highlight" the list items which had a birthday today for e.g: setting the background colour for those items, setting up a background icon for those, changing the text colour of the list item, and with all of these I faced 1 common problem: if I had to scroll the list or expand/collapse one item group (in case of ExpandableListView ), then it would end up highlighting some random items from the list, and if I continued that excercise, finally almost all items would get highlighted. Since I had used an ExpandableListView , my getGroupView method looked somewhat like this: @Override  public View getGroupView(int groupPosition, ..., ViewGroup parent) {   Person person = (Person) getGroup(groupPosition);  ...