就像标题所说,我做了一些研究并改变了我的代码,但是当我运行它时,它仍然没有禁用。知道为什么吗?
cb_leic.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
if(isChecked){
cb_leic.setEnabled(false); // disable checkbox
}
}
} );
答案 0 :(得分:1)
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.link);
cb_leic= (CheckBox) findViewById(R.id.checkBox1);
cb_leic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if (isChecked) {
Toast.makeText(Check.this, " cb_leic", Toast.LENGTH_SHORT)
.show();
cb_leic.setEnabled(false); // disable checkbox
}
}
});
}