Android的方法和属性(2)
1.RadioButton(单选按钮)
嵌入到RsdioGroup中实现单选效果
android:checkedButton="radio的id值"
int getCheckedRadioButtonId(); //获得被选中的radionutton的id
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkedButton="@+id/rb2"
>
<RadioButton
android:id="@+id/rb1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="西瓜"
/>
<RadioButton
android:id="@+id/rb2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="苹果"
/>
</RadioGroup>
代码示例
2.ImageView(图片控件)
android:src //图片的资源id
android:maxWidth //最大宽度
android:maxHeight //最大高度
android:adjustViewBounds //设置为true,则maxWidth和maxHeigth生效
3.ImageButton(图片按钮)
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxWidth="50px"
android:maxHeight="50px"
android:adjustViewBounds="true"
android:src="@drawable/a"
/>
<ImageButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/p"
/>
代码示例
4.TimePicker(时间控件)
5.DatePicker(日期控件)
//修改日期
void updateDate(int year,int monthOfYear,int dayOfMonth)
注意:monthOfYear是从0~11表示1-12月
<TimePicker
android:id="@+id/tp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<DatePicker
android:id="@+id/dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
代码示例
6.Spinner
6.1下拉列表项的配置方式
a.资源文件配置
第一步:在string.xml配置
<string-array name="citys">
<item>上海</item>
<item>长沙</item>
<item>益阳</item>
</string-array>
第二步:指定资源
android:entries="@array/citys"
b.适配器配置
第一种:资源配置
ArrayAdapter<CharSequence> adapter=ArrayAdapter.createFromResource(this, 资源id, 列表显示的样式);
第二种:列表配置
ArrayAdapter<CharSequence> adapte=new ArrayAdapter<CharSequence>(this,列表显示的样式,集合数据);
<Spinner
android:id="@+id/sp1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/city"
android:entries="@array/citys"
/>
<Spinner
android:id="@+id/sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/city"
android:entries="@array/citys"
/> <string name="city">城市</string>
<string-array name="citys">
<item>上海</item>
<item>长沙</item>
<item>益阳</item>
</string-array>
代码示例
Android的方法和属性(2)的更多相关文章
- Android的方法和属性(1)
1.Activity常用的方法 View findViewById(int id) //根据组件的ID取得组件对象 setContentView(int layoutResID) //设置布局文件,设 ...
- android中xml tools属性详解
第一部分 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果. 但是有些效果则必须在运行之后才能看见,比如这种情况:TextView在xml中没有设置任何字符,而是在activity中设置了 ...
- android中xmlns:tools属性详解
今天读到一篇总结的非常棒的文章,写的逻辑很清晰也很实用,很少见到如此棒的文章了.就原文转发过来,我把格式给整理了一下,分享给园子里的各位朋友!好久没写博客了,就为2015年的11月留份纪念吧.希望对你 ...
- 【Android】使用persist属性来调用脚本文件
Android系统中有许多属性,属性由两个部分组成:name & value,可以使用这些属性来记录系统设置或进程之间的信息交换.Android系统在启动过程时会按序从以下几个文件中加载系统属 ...
- Android开发之EditText属性详解
1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true" // 以”.”形式显示文本 ( ...
- android控件的属性
android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...
- 【转】 Android开发之EditText属性详解
原文网址:http://blog.csdn.net/qq435757399/article/details/7947862 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: ...
- Android中的windowSoftInputMode属性详解
这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下 在前面的一篇文章中 ...
- Android中Edittext的属性
//此为转载别人的,挺不错的 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true" ...
随机推荐
- win10下安装TensorFlow(CPU only)
TensorFlow安装过程 1 环境 我的安装环境:win10 + 64位 +miniconda2+miniconda创建的python3.5.5环境+pip 由于目前TensorFlow在wind ...
- 关于 sql server 基本使用的建议
1. 把现有的表插入到新表,(表不能存在),为表备份. -- select * into NewTable from OldTable (NewTable 在select 查询的 ...
- PAT 天梯赛 L1-045. 宇宙无敌大招呼 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-045 AC代码 #include <iostream> #include <cstdio&g ...
- POJ 3463 Sightseeing (次短路)
题意:求两点之间最短路的数目加上比最短路长度大1的路径数目 分析:可以转化为求最短路和次短路的问题,如果次短路比最短路大1,那么结果就是最短路数目加上次短路数目,否则就不加. 求解次短路的过程也是基于 ...
- 对 java 设计模式的一些了解 (正在学习整理中)
A .设计模式的作用 从书上摘话给你们看看 帮助我们将应用组织成容易了解,容易维护,具有弹性的架构,建立可维护的OO系统,要诀在于随时想到系统以后可能需要的变化以及应付变化的原则. 这么复杂的解释肯定 ...
- js 三元表达式 复杂写法
a = 0 b = 0 a === 0 && (a = 1,b = 2) a === 1 ? (a = 3,alert(b)) : (b = 4) a === 1 || alert(a ...
- 利用C#查看特定服务是否安装
需求:想通过C#代码来查看IIS服务或者MSMQ是否已经安装 分析:IIS服务和MSMQ安装完成后都会创建windows服务,所以我们只需要查看对应的服务是否存在即可. 准备工作: IIS服务名称:W ...
- Sybase:delete与truncate、drop区别
Sybase:delete与truncate.drop区别 区别: TRUNCATE TABLE TABLENAME:删除内容.释放空间但不删除定义. DELETE FROM TABLENAME:删除 ...
- 较常用的Math方法及ES6中的扩展
记录下与Math有关的常用方法,如:求最大值.最小值等,或者是保留几位数啥的 1.数据 let floatA = 2.325232; let floatB = 2.3456; let temporar ...
- 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
这篇文章暂时只对框架中所要用到的配置文件进行解释说明,而且是针对注解形式的,框架运转的具体流程过两天再进行总结. spring+springmvc+mybatis框架中用到了三个XML配置文件:web ...