android 控件 多项选择(CheckBox)

来源:互联网 发布:java 日志作用 编辑:程序博客网 时间:2024/05/17 02:57

1、继承关系和子类:


2、定义:

复选框

A checkbox is a specific type of two-states button that can be either checked or unchecked.

3、XML重要属性:

See CompoundButton AttributesButton AttributesTextView AttributesView Attributes

4、重要方法:

isChecked()

  setChecked(true|false)

5、实战:

布局文件 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/container"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" ><TextView     android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="复选框"    /><CheckBox     android:id="@+id/checkbox1"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:drawableLeft="@drawable/ic_launcher"    android:text="复选框"    /></LinearLayout>

参考1:http://developer.android.com/intl/zh-cn/reference/android/widget/CheckBox.html
参考2:http://www.oschina.net/question/54100_34556
0 0