我尝试使用下面链接中提到的代码来“批量禁用”按钮,它工作得很好。但是,相同的代码不适用于批量启用。
禁用代码(工作)
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);
}