Android 课程设计
陈宇
本章目标
掌握按钮组件类的定义格式;
可以在Activity中定义按钮;
EditText组件的使用;
掌握RadioGroup类和RadioButton类的使用;
掌握下拉列表Spinner的使用;
可以通过程序配置Spinner显示内容;
可以通过配置文件配置Spinner显示内容。
按钮组件:Button
按钮在人机交互截面上使用的是最多的,当提示用户进行某些选择的时候,就可以通过按钮的操作来接收用户的选择。在Android使用“<Button>”组件可以定义出一个显示的按钮,并且可以在按钮上指定相应的显示文字,Button类的继承结构如下:
↳
↳
↳
<?xml version="" encoding="utf-8"?>
<LinearLayout 定义线型布局管理器
xmlns:android="http://schemas./apk/res/android"
android:orientation="vertical" 所有组件垂直摆放
android:layout_width="fill_parent" 布局管理器宽度为屏幕宽度
android:layout_height="fill_parent"> 布局管理器高度为屏幕高度
<Button 定义按钮组件
android:id="@+id/mybut1" 定义此按钮组件的ID,为Activity程序使用
android:layout_width="fill_parent" 宽度为整个容器的宽度
android:layout_height="wrap_content" 高度为文字高度
android:textColor="#FFFF00" 文字的颜色设置为黄色的RGB码
android:textSize="12px" 设置文字大小为12像素
android:text="湖北二师"/> 设置默认的显示文本
</LinearLayout>
<?xml version="" encoding="utf-8"?>
<LinearLayout 定义线型布局管理器
xmlns:android="http://schemas./apk/res/android"
android:orientation="vertical" 所有组件垂直摆放
android:layout_width="fill_parent" 布局管理器宽度为屏幕宽度
android:layout_height="fill_parent"> 布局管理器高度为屏幕高度
<Button 定义按钮组件
android:id="@+id/mybut2" 定义此按钮组件的ID,为Activity程序使用
android:layout_width="fill_parent" 宽度为整个容器的宽度
android:layout_height="wrap_content" 高度为文字高度
android:text="CLICK" 设置默认的显示文本
android:layout_margin="30px"/> 距离左边30个像素的距离
</LinearLayout>
<?xml version="" encoding="utf-8"?>
<LinearLayout 定义线型布局管理器
xmlns:android="http://schemas./apk/res/android"
android:orientation="vertical" 所有组件垂直摆放
android:layout_width="fill_parent" 布局管理器宽度为屏幕宽度
android:layout_height="fill_parent"> 布局管理器高度为屏幕高度
<Button 定义按钮组件
android:id="@+id/mybut3" 定义此按钮组件的ID,为Activity程序使用
android:layout_width="fill_parent" 宽度为整个容器的宽度
android:layout_height="wrap_content" 高度为文字高度
android:text="陈宇老师" 设置默认的显示文本
Android课程设计 来自淘豆网m.daumloan.com转载请标明出处.