Android Development Tutorials check box

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.