Android设置RadioButton在文字的右边
2024-10-15 06:06:42
效果图如下:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <TextView
- android:id="@+id/radiobutton_textview"
- android:layout_width="fill_parent"
- android:layout_height="50dip"
- android:background="@android:drawable/title_bar"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:textSize="18dip"
- android:textStyle="bold" />
- <RadioGroup
- android:id="@+id/group"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
- <RadioButton
- android:id="@+id/button1"
- android:layout_width="fill_parent"
- android:layout_height="50dip"
- android:button="@null"
- android:drawableRight="@android:drawable/btn_radio"
- android:paddingLeft="30dip"
- android:text="Android新手"
- android:textSize="20dip" />
- <View
- android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="?android:attr/listDivider" />
- <RadioButton
- android:id="@+id/button2"
- android:layout_width="fill_parent"
- android:layout_height="50dip"
- android:button="@null"
- android:drawableRight="@android:drawable/btn_radio"
- android:paddingLeft="30dip"
- android:text="Android高手"
- android:textSize="20dip" />
- </RadioGroup>
- </LinearLayout>
- package sdfasdf.sadf;
- import android.app.Activity;
- import android.os.Bundle;
- import android.widget.RadioGroup;
- import android.widget.RadioGroup.OnCheckedChangeListener;
- import android.widget.TextView;
- public class SdfsadfasdfasdffActivity extends Activity {
- private TextView textView;
- private RadioGroup group;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- textView = (TextView) findViewById(R.id.radiobutton_textview);
- group = (RadioGroup) findViewById(R.id.group);
- // 单选按钮组监听事件
- group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- // 根据ID判断选择的按钮
- if (checkedId == R.id.button1) {
- textView.setText("Android新手");
- } else {
- textView.setText("Android高手");
- }
- }
- });
- }
- }
http://blog.csdn.net/furongkang/article/details/7272512
最新文章
- 转载 - Vultr VPS注册开通且一键快速安装PPTP VPN和电脑连接使用
- 入门:HTML:hello world!
- 递推DP URAL 1119 Metro
- LINQ之路 1: LINQ介绍
- MATLAB 函数
- 【JavaScript】JavaScript脚本代码的位置及在页面中的执行顺序
- [iOS基础控件 - 6.10.2] PickerView 自定义row内容 国家选择Demo
- Spring、基本类型属性和集合类型属性的注入
- JSP动态网站环境搭建应用中的详细步骤(Tomcat和Apache/IIS的整合)
- elasticsearch映射
- PHP字符串替换str_replace()函数4种用法详解
- 不输入密码执行SUDO命令
- 「面向打野编程」iOS多线程:CGD
- Visual Studio进行Web性能测试- Part III
- IdentityServer4关于多客户端和API的最佳实践【含多类型客户端和API资源,以及客户端分组实践】【下】
- odoo订餐系统之订单相关知识点理解
- hadoop - 基础操作
- JS书写规范
- Collections 集合工具类
- NOIp2018提高组游记