android中的单选和多选框

先展示一下效果图

大致代码如下:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="fill_parent"
 4     android:layout_height="fill_parent" >
 5
 6     <TableRow
 7         android:id="@+id/tableRow1"
 8         android:layout_width="wrap_content"
 9         android:layout_height="wrap_content" >
10
11         <TextView
12             android:id="@+id/textView1"
13             android:layout_width="wrap_content"
14             android:layout_height="wrap_content"
15             android:text="性别:"
16             android:textSize="11pt" />
17
18         <RadioGroup
19             android:layout_gravity="center_horizontal"
20             android:orientation="horizontal" >
21
22             <RadioButton
23                 android:id="@+id/radioButton1"
24                 android:layout_width="wrap_content"
25                 android:layout_height="wrap_content"
26                 android:text="男" />
27
28             <RadioButton
29                 android:id="@+id/radioButton2"
30                 android:layout_width="wrap_content"
31                 android:layout_height="wrap_content"
32                 android:text="女" />
33         </RadioGroup>
34     </TableRow>
35
36     <TableRow
37         android:id="@+id/tableRow2"
38         android:layout_width="wrap_content"
39         android:layout_height="wrap_content" >
40
41         <TextView
42             android:id="@+id/textView2"
43             android:layout_width="wrap_content"
44             android:layout_height="wrap_content"
45             android:text="喜欢的颜色:" />
46
47         <LinearLayout
48             android:layout_width="wrap_content"
49             android:layout_height="wrap_content"
50             android:orientation="vertical" >
51
52             <CheckBox
53                 android:id="@+id/checkBox2"
54                 android:layout_width="wrap_content"
55                 android:layout_height="wrap_content"
56                 android:text="红色" />
57
58             <CheckBox
59                 android:id="@+id/checkBox3"
60                 android:layout_width="wrap_content"
61                 android:layout_height="wrap_content"
62                 android:text="绿色" />
63
64             <CheckBox
65                 android:id="@+id/checkBox1"
66                 android:layout_width="wrap_content"
67                 android:layout_height="wrap_content"
68                 android:text="蓝色" />
69         </LinearLayout>
70     </TableRow>
71
72 </TableLayout>

时间: 2024-08-29 06:31:01

android中的单选和多选框的相关文章

关于将数据中的值作为复选框

问题描述 怎么将数据中的值作为复选框,然后可以动态的添加和删除复选框.求解啊 解决方案 解决方案二:CheckBoxList?items.add(数据库返回值);解决方案三:值作为复选框的什么??问题描述不清楚,打回重写.解决方案四:复选框实现绑定数据库并删除.更新信息//获取数据库信息加载到页面publicvoidGV_DataBind(){stringsqlstr="select*fromtb_inf";sqlcon=newSqlConnection(strCon);SqlData

Android中自定义PopupWindow实现弹出框并带有动画效果_Android

使用PopupWindow来实现弹出框,并且带有动画效果 首先自定义PopupWindow public class LostPopupWindow extends PopupWindow { public Lost lost; public void onLost(Lost lost){ this.lost = lost; } private View conentView; public View getConentView() { return conentView; } public L

从数据库中取得数据,复选框中与之相等则选中

问题描述 从数据库中取得数据,复选框中与之相等则选中 从数据库中取得数据,后台返回的值与前台复选框的值一致则复选框默认被选中(使用aashx处理界面) 解决方案 取到数据后 循环你要更改的 复选框,值相同的 就选中 checked 解决方案二: 用js搞就好了..你的ashx是返回数据源的吧,处理界面是什么东东.. <input type="checkbox" name="ck" value="1" />1 <input typ

在jquery中 我有个复选框的id=a 我点一个按钮就让他选中 怎么做了? (jquery)

问题描述 在jquery中 我有个复选框的id=a 我点一个按钮就让他选中 怎么做了? (jquery) 在jquery中 我有个复选框的id=a 我点一个按钮就让他选中 怎么做了? (jquery) 解决方案 $("#a").attr("checked",'true') 解决方案二: $('#bt').onClick( function(){ $('#ck').checked(); }); 大概是这么写吧,函数名记不得了

C#编程中如何获取CheckedListBox中的若干个复选框

问题描述 C#编程中如何获取CheckedListBox中的若干个复选框 在c#中如何获取checklistbox中的某几个复选框被选中的文本内容,我想将这些内容写到字符串数组中.请各位不吝赐教.请把具体的代码写给我.谢谢了. 解决方案 List<string> l = new List<string>(); foreach (object i in checkedListBox1.CheckedItems) { l.Add(i.ToString()); } string[] ar

Android中自定义PopupWindow实现弹出框并带有动画效果

使用PopupWindow来实现弹出框,并且带有动画效果 首先自定义PopupWindow public class LostPopupWindow extends PopupWindow { public Lost lost; public void onLost(Lost lost){ this.lost = lost; } private View conentView; public View getConentView() { return conentView; } public L

【Android开发】基本组件-复选框

复选框: 默认情况下,单选框按钮显示为一个方块图标,并且在该图标旁边放置一些说明性文字.与单选按钮不同的是,复选框可以进行多选设置,每一个复选框都提供"选中"和"不选中"两种状态. 在Android中,复选框使用CheckBox表示,CheckBox又是Button的子类,所以单选按钮可以直接使用Button支持的各种属性. Android中,可以使用两种方法向屏幕中添加单选按钮,一种是通过在XML布局文件中使用<CheckBox>标记添加:另一种是在J

Delphi中为TreeView添加单选和复选框

打开电脑,进入Windows操作系统,在资源管理器的左边栏中清楚地显示了系统管理的所有磁盘的信息以及各个磁盘所容纳的文件与文件夹(如图一).这种常见的显示方式是由一个根节点和若干个子节点构成的,这被称为"树形结构".这种树形结构的用途非常广泛,在很多常用软件中都出现过它的身影.Windows中将这种结构封装为"树形控件",即TreeView控件,它与ListView.Button等一样都属于系统自带的通用公共控件.在Delphi中,TreeView也被封装成了VCL

ExtJs之单选及多选框

坚持  <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="Ex