Android 如何保存资源 Id 数组在 res/values/arrays.xml 里
<resources>
<!-- Tracks Information -->
<array name="music_ids">
<item>@raw/sf_the_typewriter</item>
<item>@raw/sf_facades</item>
<item>@raw/sf_ah_vous_dirai_je_maman_k265</item>
<item>@raw/sf_jesu_meine_freude_bwv227_weicht_ihr_trauergeister</item>
<item>@raw/sf_music_of_the_spheres</item>
<item>@raw/sf_cosi_fan_tutte_k588_act_1_scene_2_terzettino_soave_sia_il_vento</item>
<item>@raw/sf_ah_vous_dirai_je_maman_k265</item>
<item>@raw/sf_clair_de_lune</item>
<item>@raw/sf_mongol_gerin_magtaal</item>
<item>@raw/sf_der_freischutz_opera_j277_act_3scene_6_jagerchor_was_gleicht_wohl_auf_erden</item>
</array>
</resources>
这些资源文件保存在了资源数组里,res/values/arrays.xml
取出:
TypedArray array = getResources().obtainTypedArray(R.array.music_ids);
int length = array.length();
int[] resIds = new int[length];
for (int i = 0; i < length; i++) {
resIds[i] = array.getResourceId(i, 0);
}
array.recycle();
Android 如何保存资源 Id 数组在 res/values/arrays.xml 里的更多相关文章
- color 颜色代码 android res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...
- Android的基本资源引用(字符串、颜色、尺寸、数组)【转】
感谢大佬:https://blog.csdn.net/wenge1477/article/details/81295763 Android的基本资源引用(字符串.颜色.尺寸.数组)[转] 一.Andr ...
- Android应用程序资源的查找过程分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8806798 我们知道,在Android系统中, ...
- Android应用程序资源的编译和打包过程分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8744683 我们知道,在一个APK文件中,除了 ...
- Android RadioGroup 及资源文件 & selector
RadioGroup :单选组 RadioButton :单选按钮 RadioButton和CheckBox的区别: 1.单个RadioButton在选中后,通过点击无法变为未选中 单 ...
- 〖Android〗Android App项目资源字符串检查(检查是否缺少对应的翻译,导致系统切换语言后崩溃)
Android项目开发过程中,容易出现缺少对应中英文翻译的情况,这个Python脚本是用于检查字符串是否缺少了对应的翻译 #!/usr/bin/env python # encoding: utf-8 ...
- Android中的资源访问
Android中的资源是指非代码部分,指外部文件. assets中保存的一般是原生的文件,例如MP3文件,Android程序不能直接访问,必须通过AssetManager类以二进制流的形式来读取. r ...
- Android 添加framework资源包
为Android系统添加一个新的资源包 概述 传统的Android系统只有一个framework-res.apk资源包,第三方厂商在进行rom定制时会直接修改framework res资源,达到适配目 ...
- 今天给大家分享一下Android中的资源与国际化的问题
摘要:该文章将向大家分享Android中的资源与国际化的问题. 今天给大家分享一下Android中的资源与国际化的问题,通常我们新建一个Android工程,目录结构如下图所示: 我们主要看一下layo ...
随机推荐
- cpu真实核数
判断依据: 1.具有相同core id的cpu是同一个core的超线程. 2.具有相同physical id的cpu是同一颗cpu封装的线程或者cores. 英文版: 1.Physical id an ...
- 温故而知新-面向对象的PHP
1 类的多态 不同的类对同一操作可以有不同的行为. 比如自行车和汽车都有移动这个成员函数行为, 那么自行车类可以移动,行为和汽车的移动行为肯定不同. 2 析构函数不能有参数 3 __set和__get ...
- Ubuntu12.04编译vlc-android详细流程
作者:wainiwann 出处:http://www.cnblogs.com/wainiwann/ 本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则 ...
- How To Install Spring IDE In Eclipse
Spring IDE is a very useful graphical user interface tool adding support for Spring Framework. In th ...
- ConcurrentDictionary内部机制粗解
ConcurrentDictionary是线程安全类,是什么在保证? 内部类 private class Tables { internal readonly Node[] m_buckets; // ...
- http post Content-type: application/json; charset=utf-8
The header just denotes what the content is encoded in. It is not necessarily possible to deduce t ...
- 基础常用JS函数和语法
100多个基础常用JS函数和语法集合大全 来源:http://www.cnblogs.com/hnyei/p/4605103.html 网站特效离不开脚本,javascript是最常用的脚本语言,我 ...
- sql产生随机数字
第一种:select cast(ceiling(rand() * 10) as int)第二种:select cast(ceiling(rand(checksum(newid()))*10) as i ...
- jquery.cookie 介绍 和 用法
1.依赖jQuery库 2.浏览器兼容性情况 3.下载 官方github:https://github.com/carhartl/jquery-cookie 4.使用 创建一个整站cookie $.c ...
- Android 4.0关于开机启动服务
针对使用App应用管理强制停止的App,重启系统后不能收到开机启动, 需要运行一次后,在下次再启动时,才可以正确收到.