Android settings RadioButton on the right side of the text

Source: Internet
Author: User

As follows:

[HTML]View Plaincopy
  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical" >
  6. <TextView
  7. android:id="@+id/radiobutton_textview"
  8. android:layout_width="fill_parent"
  9. android:layout_height="50dip"
  10. android:background="@android:d rawable/title_bar"
  11. android:gravity="center_vertical"
  12. android:textappearance="? Android:attr/textappearancelarge"
  13. android:textsize="18dip"
  14. android:textstyle="bold" />
  15. <radiogroup
  16. android:id="@+id/group"
  17. android:layout_width="fill_parent"
  18. android:layout_height="wrap_content"
  19. android:orientation="vertical" >
  20. <RadioButton
  21. android:id="@+id/button1"
  22. android:layout_width="fill_parent"
  23. android:layout_height="50dip"
  24. android:button="@null"
  25. android:drawableright="@android:d rawable/btn_radio"
  26. android:paddingleft="30dip"
  27. android:text="android Novice"
  28. android:textsize="20dip" />
  29. <View
  30. android:layout_width="fill_parent"
  31. android:layout_height="1px"
  32. android:background="? Android:attr/listdivider" />
  33. <RadioButton
  34. android:id="@+id/button2"
  35. android:layout_width="fill_parent"
  36. android:layout_height="50dip"
  37. android:button="@null"
  38. android:drawableright="@android:d rawable/btn_radio"
  39. android:paddingleft="30dip"
  40. android:text="Android Master"
  41. android:textsize="20dip" />
  42. </radiogroup>
  43. </linearlayout>
[Java]View Plaincopy
  1. Package SDFASDF.SADF;
  2. Import android.app.Activity;
  3. Import Android.os.Bundle;
  4. Import Android.widget.RadioGroup;
  5. Import Android.widget.RadioGroup.OnCheckedChangeListener;
  6. Import Android.widget.TextView;
  7. Public class Sdfsadfasdfasdffactivity extends Activity {
  8. private TextView TextView;
  9. Private Radiogroup Group;
  10. @Override
  11. public void OnCreate (Bundle savedinstancestate) {
  12. super.oncreate (savedinstancestate);
  13. Setcontentview (R.layout.main);
  14. TextView = (TextView) Findviewbyid (R.id.radiobutton_textview);
  15. Group = (radiogroup) Findviewbyid (R.id.group);
  16. //radio button Group listener events
  17. Group.setoncheckedchangelistener (new Oncheckedchangelistener () {
  18. @Override
  19. public void OnCheckedChanged (radiogroup group, int checkedid) {
  20. //Determine the selected button based on ID
  21. if (Checkedid = = R.id.button1) {
  22. Textview.settext ("Android Novice");
  23. } Else {
  24. Textview.settext ("Android Master");
  25. }
  26. }
  27. });
  28. }
  29. }

http://blog.csdn.net/furongkang/article/details/7272512

Android settings RadioButton on the right side of the text

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.