【发布时间】:2012-05-03 17:05:02
【问题描述】:
我已经尝试使用下面链接中提到的代码来“批量禁用”按钮,它工作得很好。但是,相同的代码不适用于批量启用。
Android: mass enable/disable buttons
禁用代码(工作)
TableLayout tl = (TableLayout)findViewById(R.id.table1); //
ArrayList<View> touchables = tl.getTouchables();
for(View touchable : touchables){
if( touchable instanceof Button && touchable != btnNewWord )
((Button)touchable).setEnabled(false);
}
启用代码(不工作)
btnNewWord.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TableLayout tl = (TableLayout)findViewById(R.id.table1);
ArrayList<View> touchables = tl.getTouchables();
for(View touchable : touchables){
if( touchable != btnNewWord )
((Button)touchable).setEnabled(true);
}
【问题讨论】:
-
你有什么错误吗?一旦禁用按钮并尝试再次获取 ArrayList,请尝试记录您的 ArrayList 以检查它是否包含值??
标签: android button android-tablelayout