Android Development Note ___ check box __checkbox

Source: Internet
Author: User

1 <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Android:layout_width= "Match_parent"3 Android:layout_height= "Match_parent"4 android:orientation= "vertical"5 android:padding= "10DP" >6 7     <CheckBox8         Android:id= "@+id/ck_system"9 Android:layout_width= "Match_parent"Ten Android:layout_height= "Wrap_content" One android:padding= "10DP" A android:checked= "false" - Android:text= "This is a checkbox for the system" - Android:textcolor= "#000000" the android:textsize= "17SP" /> -  -     <CheckBox -         Android:id= "@+id/ck_custom" + Android:layout_width= "Match_parent" - Android:layout_height= "Wrap_content" + Android:button= "@drawable/checkbox_selector" A android:padding= "10DP" at android:checked= "false" - Android:text= "This checkbox has changed the icon" - Android:textcolor= "#000000" - android:textsize= "17SP" /> -  - </LinearLayout>

Java

1  PackageCom.example.alimjan.hello_world;2 3 ImportAndroid.content.Context;4 Importandroid.content.Intent;5 ImportAndroid.os.Bundle;6 Importandroid.support.v7.app.AppCompatActivity;7 ImportAndroid.widget.CheckBox;8 ImportAndroid.widget.CompoundButton;9 Ten /** One * Created by Alimjan on 7/2/2017. A  */ -  -  Public classClass_3_2_1extendsAppcompatactivityImplementsCompoundbutton.oncheckedchangelistener { the  - @Override -     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.code_3_2_1); -CheckBox Ck_system =(CheckBox) Findviewbyid (r.id.ck_system); +CheckBox Ck_custom =(CheckBox) Findviewbyid (r.id.ck_custom); ACk_system.setoncheckedchangelistener ( This); atCk_custom.setoncheckedchangelistener ( This); -     } -  - @Override -      Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) { -String desc = String.Format ("You have%s this checkbox", isChecked?) Tick ":" To Uncheck "); in Buttonview.settext (DESC); -     } to  +      Public Static voidstarthome (Context mcontext) { -Intent Intent =NewIntent (Mcontext, Class_3_2_1.class); the mcontext.startactivity (intent); *     } $ Panax Notoginseng}

Android Development Note ___ check box __checkbox

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.