6复选框
对于CheckBox已经成为了复选框的典型的名词。
内容:
CheckBox的主要功能是完成复选框的操作,在用户输入信息的时候,可以一次性选择多个内容,例如:用户在选择个人兴趣爱好的时候一定会存在多个,则此时就直接使用CheckBox即可完成功能。
在Android中如果要想定义复选框,可以使用Android.widget. CheckBox类,此类定义如下:
java.lang.Object
↳ android.view.View
↳ android.widget.TextView
↳ android.widget.Button
↳ android.widget.CompoundButton
↳ android.widget.CheckBox
复选框也是一个按钮,但是要比单选钮容易一些。
| <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView 定义文本提示信息 android:id="@+id/info" 组件ID android:layout_width="fill_parent" 组件宽度 android:layout_height="wrap_content" 组件高度 android:text="您经常浏览的网址是什么:" 默认文字 /> <CheckBox android:id="@+id/url1" android:text=www.baidu.com 默认文字 android:layout_width="fill_parent" android:layout_height="wrap_content"/> <CheckBox android:id="@+id/url2" android:text="www.xinlang.com" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <CheckBox 此复选框等待以后使用activity程序进行控制,设置显示内容 android:id="@+id/url3" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout> |
在activity程序之中进行复选框的控制
CheckBox组件用于实现复选框的功能。
本文介绍了Android中CheckBox组件的使用,作为复选框的典型代表,它常用于用户一次性选择多个选项的场景。CheckBox继承自CompoundButton,可用于创建复选框,并在用户输入时提供多选功能。在实际的activity程序中,可以通过定义和控制CheckBox来实现复选框的交互。
3967

被折叠的 条评论
为什么被折叠?



