立即检查开关材料集
我有以下switchmaterial
组件:
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/my_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
在“活动创建”上,我想根据数据库值将切换器设置为True/false:
@Override
protected void onCreate(Bundle savedInstanceState) {
//***
myToggle.setChecked(defaultValue);
}
问题是,当创建活动时,我可以看到组件切换到我设置的状态。是否可以立即设置状态 - 而无需运行Toogle动画吗?例如,在这个第三方库可以通过setCheckedimmass() 代码>。但是,我在
switchmaterial
中看不到此类选项。
I have following SwitchMaterial
component:
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/my_toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
On activity creation, I want to set the switcher to true/false, based on the database value:
@Override
protected void onCreate(Bundle savedInstanceState) {
//***
myToggle.setChecked(defaultValue);
}
The problem is, that when the activity is created, I can see the component to toggle to the state that I set. Is it possible to set the state immediately - without running toogle animation? For example, in this third party library, it can be achieved by setCheckedImmediately()
. However, I can see no such option in SwitchMaterial
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论