![c4de5ef4ba91c6ee9687abcbd2bd7482.png](https://img-blog.csdnimg.cn/img_convert/c4de5ef4ba91c6ee9687abcbd2bd7482.png)
实验四 Android 用户界面
一、实验目的
1. 加深对用户界面的控件的理解和使用。
2.掌握各种界面布局的用法。
3.掌握选项菜单、子菜单和快捷菜单的使用方法。
二、实验内容
1. 建立一个“ButtonDemo”的程序,包含 Button 和 ImageButton 两个按钮,上方是 “Button 按钮”,下方是一个 ImageButton 控件?
2. 建立一个“CheckboxRadiobuttonDemo”程序,包含五个控件,从上至下分别是 TextView01 、 CheckBox01 、 CheckBox02 、 RadioButton01 、 RadioButton02 , 当选择 RadioButton01, RadioButton02 则无法选择?
3.建立一个“TabDemo”程序,包含三个 XML 文件,分别为 tab1.xml、tab2.xml 和 tab3.xml,这 3 个文件分别使用线性布局、相对布局和绝对布局示例中的 main.xml 的代码, 并将布局的 ID 分别定义为 layout01、layout02 和 layout03?
4.建立一个“MyContextMenu”程序,来完成 Android 菜单的功能。 三、实验仪器、设备 硬件:PC 微型计算机、1G 以上内存,40G 以上硬盘 软件:Windows XP,Eclipse , JDK , Android SDK
三、实验仪器、设备:
硬件:PC 微型计算机、1G 以上内存,40G 以上硬盘
软件:Windows XP,Eclipse , JDK , Android SDK
四、实验代码及结果
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"/>
<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button01" >
</Button>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="150dp"
android:layout_height="150dp">
</ImageButton>
<TextView android:id="@+id/TextView02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="复选框调试"/>
<CheckBox android:id="@+id/CheckBox01"
android:layout_width="wrap_con