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-hdpi/
icon.png
drawable-ldpi/
icon.png
drawable-mdpi/
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
"Resource" that contains the tokens for each one of the resources included. For example,
for the above Resources layout, this is what the Resource class would expose:
public class Resource {
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 Resource.layout.main
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
string in the dictionary file values/strings.xml.
Android 一个最最基础的图形程序,圆可以拖动,两点触控是删除圆,3点触控是添加一个圆-IT计算机-毕业设计.zip
版权申诉
195 浏览量
2022-04-05
20:32:55
上传
评论
收藏 2.03MB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/cb3ef9cd632345779e6826b47461fb9e_qq_27489007.jpg!1)
芝麻粒儿
- 粉丝: 6w+
- 资源: 2万+
最新资源
- RB305A-SOT-23封装 单节锂电池保护IC 深圳市可芯电子有限公司.pdf
- javaweb 期末复习
- unity简单数字拼图小游戏(源码)
- 危包证办理培训教材(出境危险货物运输包装使用鉴定结果单)
- Vissim9 用户手册(英文版)
- 基于Selenium的Java爬虫实战(内含谷歌浏览器Chrom和Chromedriver版本124.0.6350.0)
- ThinkPHP微信独立互换红包系统开源版.zip
- ChromeDriver-87.0.4280.88.zip 下载
- RB306A-SOT23-5封装 单节锂电池保护IC 深圳市可芯电子有限公司.pdf
- IMG_20240615_134614.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)