android——array中设置选项
Android中,R.array是提取XML资源文件中String数组的方法。具体定义和提取的方法如下:
1)在R.array中定义字符数组
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="city">
<item>厦门市</item>
<item>福州市</item>
<item>泉州市</item>
<item>漳州市</item>
<item>龙岩市</item>
</string-array>
</resources>
2)在代码中获取数组信息
Resources res =getResources();
String[] city=res.getStringArray(R.array.city);
注:对于定义图片数组的方法为:(1)在在drawable目录下创建一个animation.xml,如:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/icon1" android:duration="150"></item>
<item android:drawable="@drawable/icon2" android:duration="150"></item>
<item android:drawable="@drawable/icon3" android:duration="150"></item>
<item android:drawable="@drawable/icon4" android:duration="150"></item>
<item android:drawable="@drawable/icon5" android:duration="150"></item>
<item android:drawable="@drawable/icon6" android:duration="150"></item>
</animation-list>
(2)在代码中可直接在layout中android:src="@drawable/animation" 引用。
android——array中设置选项的更多相关文章
- Android代码中设置字体大小,字体颜色,显示两种颜色.倒计时效果
Android代码中设置字体大小,字体颜色,显示两种颜色 在xml文件中字体大小用的像素 <TextView android:id="@+id/uppaid_time" an ...
- Android线程中设置控件
在Android中经常出现多线程中设置控件的值报错的情况,今天教大家封装一个简单的类避免这样的问题,同样也调用实现也非常的方便. 自定义类: /** * Created by wade on 2016 ...
- android studio 中设置apk的版本号
今天在mainfest.xml中设置版本号为2,(代码获取到的版本号无效) android:versionCode="2" android:versionName="2. ...
- Android系统中设置TextView的行间距(非行高)
Android系统中TextView默认显示中文时会比较紧凑,不是很美观.为了让每行保持一定的行间距,可以设置属性android:lineSpacingExtra或android:lineSpacin ...
- android 项目中设置背景图片
xml文件设置背景图片中:任意一个控件,button imageView 或layout,在其的xml属性设置中,添加 [XML] view plaincopy android:background= ...
- Android Studio中设置提示函数用法
Eclipse有一个很好的功能,就是当你代码调用某个android API时,鼠标移到对应的函数或者方法上,就会自动有一个悬浮窗提示该函数的说明(所包含的参数含义,该方法功能).迁移到Android ...
- android RadioGroup中设置selector后出现多个别选中的RadioButton的解决办法
在一个RadioGroup组中假如有三个或者以上的RadioButton,当然你需要给这些RadioButton设置selector.设置其中的一个为默认选中状态(在xml中设置).当程序在手机上运行 ...
- Android RadioGroup中设置默认选中RadioButton 后,选中两个的问题 解决方法
项目中遇到多个RadioGroup中单选RadioButton ,设置了默认选中第一个 . 然后就 能选中两个RadioButton . . .. 我开始这样给设置默认选中一个的: for (int ...
- android -------- android studio 中设置创建类时的说明信息(包含 作者 ,创建时间,注释说明等)
今天简单来说一下android studio开发工具中的 一个小设置功能: 在开发过程中我们习惯给新建的类添加一些注释信息,创建日期.时间和作者等. 设置信息 File—>Settings—&g ...
随机推荐
- (3)一般处理程序 ,HttpContext类
一般处理程序的后缀名 .ashx ,专门用来处理web请求 新建后默认代码: public class Handler1 : IHttpHandler { public void ProcessRe ...
- 透明代理Transparent Proxy
透明代理Transparent Proxy 透明代理Transparent Proxy类似于普通代理,它可以使得处于局域网的主机直接访问外网.但不同之处,它不需要客户端进行任何设置.这样,客户端误 ...
- ApplicationContext介绍
如果说BeanFactory是Spring的心脏,那么ApplicationContext就是完整的身躯了.ApplicationContext由BeanFactory派生而来,提供了更多面向实际应用 ...
- yii框架:CDbConnection failed to open the DB connection: could not find driver的解决的方法
这个问题是由于php中缺少pdo mysql造成的. 解决方法是为php加入此扩展.前往你最早的php安装文件,进入ext/pdo_mysql/文件夹下,然后./configure --with-ph ...
- 转: linux下的自动对时
转自: http://www.cnblogs.com/vimmer/archive/2012/05/17/2505785.html 评注:date 命令格式为: date -s 2012-08-02 ...
- 【Sprint3冲刺之前】日历表的事件处理和管理(刘铸辉)
我的Sprint2冲刺——日历表的事件处理和管理(刘铸辉,刘静) 我的Sprint2冲刺计划领到的任务是和静姐结对编程,完成日历表的事件处理和管理,下面详细讲解下技术细节. 1.设计结构图 首先要画出 ...
- USB通讯协议
首先要了解USB枚举过程(自己百度) https://blog.csdn.net/MyArrow/article/details/8270029 USB通讯协议 0. 基本概念 一个[传输](控制.批 ...
- javascript 高级编程系列 - 继承
1. 原型链继承 (缺点:子类继承父类的引用类型的属性值会在各个实例中共享,创建子类实例时无法向父类构造函数传递参数) // 定义父类构造函数 function SuperClass(father, ...
- 简单的看Unicode和UTF-8的区别
作者:uuspider链接:http://www.zhihu.com/question/23374078/answer/65352538来源:知乎著作权归作者所有,转载请联系作者获得授权. 举一个例子 ...
- poj 1703 Find them, Catch them(种类并查集和一种巧妙的方法)
Find them, Catch them Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36176 Accepted: ...