Search code examples
androidcheckboxdrawingexpandablelistviewexpandablelistadapter

re-draw effect on expanding/collapsing listView contains CheckBoxes


I have an Expandable ListView contains CheckBoxes in both groupViwes and groups childViews. When having one/more checkBox checked, it causes a re-draw effect on expanding/collapsing any of the groupViews of the listView, please check the following:

enter image description here

As you see, when collapsing group KG-1 after expanding, the group grade 5 is being shifted up to a new position, which gives a bad flickering effect of the group named 1 as it (and its child) takes a while to re-draw the unchecked state as it took the position of a checked group which is grade 5.

So, how to get rid of that re-draw effect? or even to delay the collapse if that would solve the problem.


Solution

  • Call jumpDrawablesToCurrentState() on CheckBox right after calling setChecked(). It will skip the state change animation of CheckBox.

    checkBox.setChecked(false);
    checkBox.jumpDrawablesToCurrentState();