在 Android 中,ToggleButton 状态以编程方式更改,而不是自动更改?
我创建了一个扩展 ToggleButton 的自定义类,并且覆盖了切换方法并且不执行任何操作。这帮助我控制了切换按钮从开到关的切换。这是正确的做法吗?
我想要控制切换按钮的切换。我的意思是它应该根据某些条件从开到关,否则它应该保持原来的状态。
这种方式可以工作,但想知道这是否是正确的做法。
I have created a custom class which extends ToggleButton and I override the toggle method and do not do anything in that. This has helped me in having control of switching togglebutton from on to off. Is this proper way of doing?
I wanted to have the control of togglebutton switching. I mean it should go from on to off based on certain conditions otherwise it should remain in the state it was.
This way its working but want to know whether its the correct way of doing or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找的是
ToggleButton.setChecked
。What you are looking for is
ToggleButton.setChecked
.