CheckBox的使用
首先在XML布局文件中添加CheckBox控件,用于定义复选框
<CheckBox android:id="@+id/checkBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CheckBox" />
为CheckBox设置监听器
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { } });
使用isChecked判断复选框是否被选中
浙公网安备 33010602011771号