Basic application of the single box for Android development entry

Source: Internet
Author: User
Tags gettext

As Android phones get more and more hot, the Android OS is also popular with developers, and many programmers are slowly switching to Android development. Today, the Wheat Academy's Android development teacher told everyone about Android Radio basic applications, and today we followed the Wheat Academy Android teacher to learn how the Android radio box was implemented.

When using the Android radio box, use Radiogroup to group
When you select the Radiogroup in the box, the Radiogroup check is called () method
When the Append radio box is selected for processing,
1. Call the Setoncheckedchangelistener () method and pass the Radiogroup.oncheckedchangelistener instance as a parameter
2. In Radiogroup.oncheckedchangelistener's OnCheckedChanged () method, obtain an instance of the selected Android radio box
Example Routines Code (JAVA)

1. View Sourceprint?01.radiogroup Radiogroup = (radiogroup)

2. Findviewbyid (Id.radiogroup);

3. Radiogroup.check (Id.radiobuttongreen);

4. Radiobuttonradiobutton = (RadioButton) Findviewbyid (

5. Radiogroup.getcheckedradiobuttonid ());

6. LOG.V ("Test", String.valueof (Radiobutton.gettext ()));

7. Radiogroup.setoncheckedchangelistener (

8. Newradiogroup.oncheckedchangelistener () {

9. Public Voidoncheckedchanged (

10.RadioGroupgroup,

11.int Checkedid) {

12.RadioButtonradioButton = (RadioButton) Findviewbyid (Checkedid);

13.LOG.V ("Test", String.valueof (Radiobutton.gettext ()));

14.}

15.});



Example Routines Code (RESOURCE)

1. < radiogroupandroid:id= "@+id/radiogroup"

2. Android:layout_width= "Wrap_content"

3. android:layout_height= "Wrap_content" >

4. < radiobuttonandroid:id= "@+id/radiobuttonred"

5. Android:layout_width= "Wrap_content"

6. android:layout_height= "Wrap_content"

7. android:text= "@string/red"/>

8. < radiobuttonandroid:id= "@+id/radiobuttongreen"

9. Android:layout_width= "Wrap_content"

10.android:layout_height= "Wrap_content"

11.android:text= "@string/green"/>

12.< radiobuttonandroid:id= "@+id/radiobuttonblue"

13.android:layout_width= "Wrap_content"

14.android:layout_height= "Wrap_content"

15.android:text= "@string/blue"/>

</radiogroup>

For Android Development tutorials, go to:Http://www.maiziedu.com/course/android/

Basic application of the single box for Android development entry

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.