在android中选中两个复选框后如何使按钮可点击
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok1" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok2" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start" />
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final CheckBox ch1 = (CheckBox)findViewById(R.id.checkBox1);
final CheckBox ch2 = (CheckBox)findViewById(R.id.checkBox2);
final Button start = (Button)findViewById(R.id.button1);
if(ch1.isChecked() && ch2.isChecked()){
start.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG);
}
});
}
}
我是编程新手
提前致谢