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" ...
随机推荐
- python 测试代码
1.使用print()打印 测试代码最简单的就是添加一些print()语句.然而产品开发中,需要记住自己添加的所有print()语句并在最后删除,很容易出现失误. 2.使用pylint.pyflake ...
- 用pytesseract识别验证码报错
运行py文件出现下面报错 pytesseract.pytesseract.TesseractError: (1, 'Error opening data file \\Program Files\\T ...
- LeetCode:课程表【207】
LeetCode:课程表[207] 题目描述 现在你总共有 n 门课需要选,记为 0 到 n-1. 在选修某些课程之前需要一些先修课程. 例如,想要学习课程 0 ,你需要先完成课程 1 ,我们用一个匹 ...
- top下的快捷键
M —根据驻留内存大小进行排序 P —根据CPU使用百分比大小进行排序 T —根据时间/累计时间进行排序 c —切换显示命令名称和完整命令行 t —切换显示进程和CPU信息 m —切换显示内存信息 l ...
- node-inspector使用方法
开发node.js程序使用的是javascript语言,其中最麻烦的还是调试,这里介绍一下node-inspector使用方法.具体资料可以看参考资料中的GITHUB文档. 方法/步骤 使用命令$ ...
- [转]从程序员到CTO的Java技术路线图
原文链接:http://zz563143188.iteye.com/blog/1877266 在技术方面无论我们怎么学习,总感觉需要提升自已不知道自己处于什么水平了.但如果有清晰的指示图供参考还是非常 ...
- 【JavaScript】键盘控制小球
参考: 1.Simple Canvas Game 2.javaScript 事件监听 <!DOCTYPE html> <html> <head> <meta ...
- java的arrayCopy用法
java的arrayCopy用法 final , ); //System.arraycopy(samplesConverted, 0, bytes, 0, 1024); 先贴上语法: publ ...
- kafka和canal设置为开机启动
1.切换到初始化目录 cd /etc/init.d/ 2.新建一个文件 如 touch autoupdate 3.vim autoupdate #!/bin/bash export JAVA_HOME ...
- NO.2 You must restart adb and Eclipse多种情形分析与解决方案
一.问题描述: 运行android程序控制台输出 The connection to adb is down, and a severe error has occured. ...