Bos*_*one 6 android button tablelayout
我有一个活动,其中一堆按钮放在TableLayout内,与拨号盘不同.在某些操作中,我需要暂时禁用按钮.令我不愉快的惊喜TableLayout.setEnabled(false),对嵌套按钮没有任何影响.我是坚持设置每个单独的按钮还是有一个漂亮(更好)的方式来实现相同的?
我会尝试这样做:
TableLayout tableLayoutInstance; // let's suppouse you have already initialized it
// blablabla
// example to deactivate all buttons
ArrayList<View> touchables = tableLayoutInstance.getTouchables();
for(View touchable : touchables){
if( touchable instanceof Button )
((Button)touchable).setEnabled(false);
}
Run Code Online (Sandbox Code Playgroud)