android常用UI控件的使用例子

之前有几个好朋友说最近android很火,很想学习下android,在他们的要求下,我给他们讲解了android的一些基础知识,带他们进入android的大门,以下是讲解课程中的第二课,常用UI控件的使用,第一课主要是android的一些简单介绍和环境的搭建,这个可以参考我之前的环境搭建的文章,这些都是比较基础的东西,对初学者有帮助而已,大虾们就不需要浪费时间了。以下这个xml文件中是包含了该课程中的全部UI控件了。

register.xml
[code]
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nameLable"
android:id="@+id/nameLable"
android:textColor="@drawable/red"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/nameLable"
android:layout_marginLeft="45px"
android:id="@+id/name"
android:maxLength="30"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pwdLable"
android:id="@+id/pwdLable"
android:textColor="@drawable/white"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/pwdLable"
android:layout_marginLeft="45px"
android:id="@+id/pwd"
android:password="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cfmpwdLable"
android:id="@+id/cfmpwdLable"
android:textColor="@drawable/other"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/cfmpwdLable"
android:layout_marginLeft="17px"
android:id="@+id/cfmpwd"
android:password="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/emailLable"
android:id="@+id/emailLable"
android:textColor="@drawable/gray"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/emailLable"
android:layout_marginLeft="45px"
android:id="@+id/email"
android:autoLink="email"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sexLable"
android:id="@+id/sexLable"
android:textColor="@drawable/magenta"
/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/sexLable"
android:layout_marginLeft="15px"
android:layout_alignTop="@id/sexLable"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<RadioButton
android:layout_width="70px"
android:layout_height="wrap_content"
android:id="@+id/male"
android:text="@string/maleLable"
android:checked="true"
android:textStyle="italic"
/>
<RadioButton
android:layout_width="80px"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/male"
android:id="@+id/female"
android:layout_alignTop="@id/male"
android:text="@string/femaleLable"
android:textStyle="italic"
/>
</RelativeLayout>
</RadioGroup>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/birthdayLable"
android:id="@+id/birthdayLable"
android:textColor="@drawable/ltgray"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/birthdayLable"
android:layout_marginLeft="15px"
android:id="@+id/birthday"
android:singleLine="true"
android:clickable="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/degreeLable"
android:id="@+id/degreeLable"
android:textColor="@drawable/green"
/>
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/degreeLable"
android:layout_marginLeft="15px"
android:id="@+id/degree"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skillLable"
android:id="@+id/skillLable"
android:textColor="@drawable/dkgray"
android:textStyle="bold"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/skillLable"
android:layout_marginLeft="15px"
android:text="java"
android:id="@+id/java"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/java"
android:layout_marginLeft="15px"
android:id="@+id/j2ee"
android:text="j2ee"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/j2ee"
android:layout_marginLeft="15px"
android:id="@+id/android"
android:text="android"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remarkLable"
android:id="@+id/remarkLable"
android:background="@drawable/yellow"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/remarkLable"
android:layout_marginLeft="15px"
android:id="@+id/remark"
android:minLines="3"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/submitBtn"
android:layout_marginLeft="50px"
android:src="@drawable/selectcity"
android:tag="@string/submitBtn"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/resetBtn"
android:layout_toRightOf="@id/submitBtn"
android:layout_marginLeft="30px"
android:text="@string/resetBtn"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/backBtn"
android:layout_toRightOf="@id/resetBtn"
android:layout_marginLeft="30px"
android:text="@string/backBtn"
/>
</RelativeLayout>

</LinearLayout>
</ScrollView>

[/code]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值