android实验2界面设计:基本组件
西 安 邮 电 大 学
(计算机学院)
课内实验报告
实验名称: 界面设计:基本组件
专 droid:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Spinner android:id="@+id/dept"
android:entries="***@array/dept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<!-- 在主布局中添加爱好文本框和一个线性布局 -->
<TextView
android:text="***@string/hobby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox android:id="@+id/book"
android:text="***@string/book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox android:id="@+id/sport"
android:text="***@string/sport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox android:id="@+id/music"
android:text="***@string/music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<CheckBox android:id="@+id/movie"
android:text="***@string/movie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button android:id="@+id/ok"
android:layout_gravity="center_horizontal"
android:text="***@string/ok"
android:onClick="myclick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
(3)检测布局的后的效果
表示部门的Spinner组件, 位于res/values目录下,代码如下所示
编写数据文件
<?xml version="" encoding="utf-8"?>
<resources>
<string-array name = "dept">
<item>人力资源部</item>
<item>销售部</item>
<item>财务部</item>
<item>开发部</item>
</string-array>
</resources>
查看视图效果
设计后台程序
在Activity文件中,定义局部中的组件对象和一个存放爱好中个复选对象的favs动态数组。
//1. 用户名 密码 联系电话
private EditText u
android实验2界面设计:基本组件 来自淘豆网m.daumloan.com转载请标明出处.