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" ...
随机推荐
- 学点TCPDUMP
[root@future ~]# yum install tcpdump 官网地址: https://nmap.org/ 还有中文手册,太感动了 https://nmap.org/man/zh/man ...
- 经典排序算法的总结及其Python实现
经典排序算法总结: 结论: 排序算法无绝对优劣之分. 不稳定的排序算法有:选择排序.希尔排序.快速排序.堆排序(口诀:“快速.选择.希尔.堆”).其他排序算法均为稳定的排序算法. 第一趟排序后就能确定 ...
- PHP获取与操作php.ini文件的几个函数示例
php有一套设置和获取配置信息的函数,用于设置与修改相关参数信息. 1.ini_get()获取配置参数,ini_set()设置配置参数 <?php 2.ini_get_all()获取所有配置 ...
- mysql 练习题(Day44)
init.sql文件内容 /* 数据导入: Navicat Premium Data Transfer Source Server : localhost Source Server Type : M ...
- CNN学习笔记:线性回归
CNN学习笔记:Logistic回归 线性回归 二分类问题 Logistic回归是一个用于二分分类的算法,比如我们有一张图片,判断其是否为一张猫图,为猫输出1,否则输出0. 基本术语 进行机器学习,首 ...
- Windows 下c获取文件目录
由于要插数据库,构建sql语句,需要文件名,在网上找了半天,无奈都是Linux下的专用函数,伤心,,还有那个下载URL ,还木搞好,就要走啦,心焦哇 #include<iostream> ...
- 优秀 H5 案例收集 vol.1(不定期更新)
一生要历经的三种战斗http://datang.wearewer.com/ 雍正去哪儿http://news.163.com/college/special/craftsman_h5/ 比Emoji更 ...
- JSP与Servlet之后台页面单条删除与多条删除的页面跳转之实现
单条删除页面跳转 1.首先打开JSP页面,找到删除 2.这个时候要把它改成servlet的URL,并决定要传给后台什么数据,例如我需要传一个待删数据的ID id并不是什么见不得人的东西(而且是后台也不 ...
- Django---自定义admin组件思维导图
- Tomcat 线程池配置
线程池 Executor代表了一个线程池,可以在Tomcat组件之间共享.使用线程池的好处在于减少了创建销毁线程的相关消耗,而且可以提高线程的使用效率.要想使用线程池,首先需要在 Service标签中 ...