Android: Mass validation / deactivation buttons

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?

I’d try to do something like this:

TableLayout tableLayoutInstance; // let's suppouse you have already initialized it
// blablabla
// example to deactivate all buttons
ArrayList touchables = tableLayoutInstance.getTouchables();
for(View touchable : touchables){
    if( touchable instanceof Button )
        ((Button)touchable).setEnabled(false);
}
Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » Android: Mass validation / deactivation buttons

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录