In front of the Wheat Academy's Android development teacher to introduce you to the Android Development tutorial single box in detail, today the Wheat Academy's Android development teacher gave you some basic contents of Android check box.
Call the Setchecked () method when setting the check status of the checkbox
The Append Android check box is selected when processing,
1. Call the Setoncheckedchangelistener () method and pass the Compoundbutton.oncheckedchangelistener instance as a parameter
2. In Compoundbutton.oncheckedchangelistener's OnCheckedChanged () method, obtain an instance of the selected Android check box
Example Routines Code (JAVA)
1.CheckBox checkbox = (checkbox) Findviewbyid (id.checkbox);
2.checkbox.setchecked (true);
3.checkbox.setoncheckedchangelistener (
4.new Compoundbutton.oncheckedchangelistener () {
5. @Override
6.public void OnCheckedChanged (
7.CompoundButton Buttonview,
8.boolean isChecked) {
9.CheckBox checkbox = (checkbox) Buttonview;
10.log.v ("Test", String.valueof (Checkbox.gettext ()) +
One . "is" + string.valueof (isChecked));
.}
.});
Example Routines Code (RESOURCE)
1.< checkbox android:id= "@+id/checkbox"
2.android:layout_width= "Wrap_content"
3.android:layout_height= "Wrap_content"
4.android:text= "@string/test"/>
for an Android development tutorial, go to:Http://www.maiziedu.com/course/android/
Android Development Tutorials check box