androidlistviewinvalidationredraw

Android ListView element invalidate() does not redraw


In my Android App, I have a ListView which contains several elements. For certain user inputs (touch events), it happens that one element in the ListView calls invalidate() on itself. The problem is that sometimes, the element then redraws itself and sometimes not. When it does not redraw itself after invalidate() has been called, I need to scroll the ListView in order to get the desired redraw. Of course, I don't want that. It is to mention that I never call listview.invalidate() but only element.invalidate(). Has anyone an idea on how to fix this?


Solution

  • As we all get older, we get wiser. My problem was that I did not use convertView in the Adapter's getView method but kept all the views in an ArrayList. Bad practice, ladies and gents. Use convertView and everything will work buttery smooth.