Android check box source code parsing

Source: Internet
Author: User

Android is an open-source mobile phone operating system launched by Google based on the Linux platform. We once introduced the system architecture of this system in the previous article. I believe you can have a preliminary understanding of this system. Here, you can fully understand the basic concepts of the Android check box.

  • Android 2.1 AIDS Nexus One vs. iPhone
  • Google Android: survival or extinction
  • MOTO released Android app store for China
  • Android simulators correct application and installation methods
  • Analysis of the basic architecture mode of Android

● Call the setChecked () method when setting the Check status of the Check box.

● When the append Android check box is selected,

1. Call the setOnCheckedChangeListener () method and pass the CompoundButton. OnCheckedChangeListener instance as a parameter.

2. In the onCheckedChanged () method of CompoundButton. OnCheckedChangeListener, obtain the instance of the selected Android check box.

Routine source 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()) +  
  11. " is " + String.valueOf(isChecked));  
  12. }  
  13. }); 

Routine source 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" /> 

The basic application of the Android check box is introduced here.

Related Article

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.