Change Switch state without animation

前端 未结 7 1933
醉酒成梦
醉酒成梦 2020-12-09 07:54

In my Android project, I have a ListView with rows containing SwitchCompat items (AppCompat for Switch widget).

My problem occ

7条回答
  •  借酒劲吻你
    2020-12-09 08:31

    I finally found a solution but seems not really clean:

    ViewGroup viewGroup = (ViewGroup) view; // the recycled view
    viewGroup.removeView(switch);
    switch.setChecked(states[index]);
    viewGroup.addView(switch);
    

    If a better solution exists, please share it.

提交回复
热议问题