Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.xml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable/
icon.png
layout/
main.xml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.xml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

qq_小太阳很忙
- 粉丝: 0
最新资源
- 移动互联成为全球软件产业投融资重点关注领域(2014-).docx
- 基于s3c2410的模拟智能家居系统方案设计书.doc
- 教你用EXCEL绘制施工进度计划横道图.docx
- 浅析互联网+背景下中学英语阅读教学策略.docx
- 后MOOC时代高等医药院校计算机基础课重构与创新模式研究.docx
- 计算机科学与技术专业实践教学体系的构建.docx
- 计算机操作系统-司机与售票员的进程问题.doc
- (源码)基于嵌入式C编程语言的汽车温度监测与管理系统.zip
- 单片机C语言程序设计方案师试题.doc
- VB的图书管理系统方案设计书与实现1.doc
- 中铁四局大数据时代的企业信息化建设.docx
- 基于 RV1106 开发的神经网络模型部署仓库,已支持 PicoDet、MobileNet、CRNN、PPHumanSeg、OCR 及 YOLOv5 等模型
- 项目管理10大模板Excel版.xls
- 如何快速将cad转换成pdf.docx
- (源码)基于Python的网络简易英英词典.zip
- PHP-Mysql-音乐交流论坛的设计与实现评阅书-(含所有设计文档).doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



评论0