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.axml),
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.axml
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.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

dotnet全栈开发
- 粉丝: 2w+
最新资源
- Delphi跨平台开发陷阱:Android权限管理与资源冲突解决.pdf
- Delphi跨平台UI设计:响应式布局与属性绑定高级技巧.pdf
- Delphi跨平台开发:Linux环境下VCL组件兼容性处理.pdf
- Delphi旅游行业应用:GPS集成与实时行程规划算法.pdf
- Delphi聊天机器人:AI对话系统开发与自然语言处理.pdf
- Delphi跨语言交互:JNI调用Java模块的完整流程解析.pdf
- Delphi面向对象编程精要:类继承体系与多态性实战设计模式.pdf
- Delphi密码学应用:AES-256加密与企业级安全通信.pdf
- Delphi模块化设计精要:接口隔离与依赖注入解决循环引用.pdf
- Delphi内存优化终极方案:FastMM4配置与泄漏检测案例.pdf
- Delphi内存安全终极指南:FastMM4全内存快照与泄漏追踪.pdf
- Delphi内存管理终极指南:New、Dispose与GetMem、FreeMem的深度对比与实践.pdf
- 卷三考试重点长长长一点.pdf
- Delphi企业架构设计:多层系统容错与高可用性实现.pdf
- Delphi能源管理系统:实时监控与节能优化开发.pdf
- Delphi农业应用:物联网传感器在智能农场中的实践.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
前往页