在没有动画的情况下更改 Switch 状态 [英] Change Switch state without animation
本文介绍了在没有动画的情况下更改 Switch 状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 Android 项目中,我有一个 ListView
,其中的行包含 SwitchCompat
项(AppCompat for Switch
小部件).
In my Android project, I have a ListView
with rows containing SwitchCompat
items (AppCompat for Switch
widget).
当我滚动到列表中并且使用 recycled
视图调用 MyAdapter
的 getView(...)
方法时,我的问题出现了.我重新定义了正确的 Switch
状态,但动画是可见的.
My problem occurs when I scroll into the list and getView(...)
method of MyAdapter
is invoked with a recycled
view. I redefine the correct Switch
state but the animation is visible.
在这种情况下有没有办法防止动画?
There is a solution to prevent the animation in this case?
推荐答案
调用jumpDrawablesToCurrentState()
跳过动画
switchCompat.setChecked(true);
switchCompat.jumpDrawablesToCurrentState();
这篇关于在没有动画的情况下更改 Switch 状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文