Android:批量启用/禁用按钮
我有一个活动,其中将一堆按钮放置在 TableLayout 内,就像拨号盘一样。在某些操作过程中,我需要暂时禁用按钮。令我不愉快的是,执行 TableLayout.setEnabled(false)
对嵌套按钮没有任何影响。我是否坚持设置每个单独的按钮,或者是否有一个漂亮(更好)的方法来实现相同的目的?
I have an activity where a bunch of buttons are placed inside TableLayout, not unlike a dial pad. During some operations I need to temporarily disable the buttons. To my unpleasant surprise doing TableLayout.setEnabled(false)
has no effect on the nested buttons. Am I stuck with setting each individual button or is there a nifty (better) way to achieve the same?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会尝试做这样的事情:
I'd try to do something like this:
我认为您必须将每个按钮设置为停用。为了使它看起来更好一点,您可以将所有按钮放在一个列表中,并在激活和停用期间迭代它们。但这不会阻止您在代码中一次找到它们。
I think you have to set each individual of this Buttons to deactivated. To make it look a little bit nicer you could put all of the buttons in a list and iterate over them during activating and deactivating. But this will not prevent you from finding them all once in you code.
由于按钮嵌套在 TableLayout 下,因此应该很容易迭代子级并设置每个按钮。不知道有没有更简单的方法。
Since the buttons are nested under a TableLayout, it should be easy to iterate over the children and set each one. I don't know if there is an easier way.