简体   繁体   中英

How to add R.drawable resources to an array for android?

我想在整数数组中调用R.drawable集的序列,以便以后可以通过选择访问它,但是我想动态地加载到R.drawable中,它对应于不同的名称。根据外部值输入没有进行硬编码。我尝试了很多,但是喜欢使用列表,集合,数组转换等。请在这方面为我提供一个片段或示例。谢谢。

I suppose, that best way to achieve this funcionality is by using ArrayAdapter of Integer .

You will simply add drawble resources by id.

If you need to get resource id, but you will get string input from user, you can use this code:

Android, getting resource ID from string?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM