`
lee79
  • 浏览: 107629 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Accessing Android Resources By Name at Runtime

阅读更多

For example: I have a file bug.png in the "/res/drawable/ ", so i get its ResourceID with the following code:

 

int resID = getResources( ) .getIdentifier ( "org.anddev.android.testproject:drawable/bug" , null , null ) ;
// or
int resID = getResources( ) .getIdentifier ( "bug" , "drawable" , "org.anddev.android.testproject" ) ;

 

 

分享到:
评论

相关推荐

    Apache Geronimo 2.1_ Quick Reference.pdf

    This material is copyright and is licensed for the sole use by Jillian Fraser on 20th November 2009 111 Sutter Street, Suite 1800, San Francisco, , 94104 Download at WoweBook.Com Table of Contents [ ...

    Direct Memory Access in Linux.doc

    - **Kernel Module**: A piece of code that can be loaded or unloaded into the kernel at runtime, providing additional functionality. #### Understanding the Challenge The original poster is working on...

    微软内部资料-SQL性能优化3

    Some of the resources have “sub-resources.” The followings are sub-resources displayed by the sp_lock output: Database Lock Sub-Resources: Full Database Lock (default) [BULK-OP-DB] – Bulk Operation...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The format of the symbol name should be <PROJECT>_<PATH>_<FILE>_H_. To guarantee uniqueness, they should be based on the full path in a project's source tree. For example, the file foo/src/bar/baz.h...

    微软内部资料-SQL性能优化5

    A clustered index is like a telephone directory in which all of the rows for customers with the same last name are clustered together in the same part of the book. Just as the organization of a ...

    Professional C# 3rd Edition

    The Common Language Runtime 4 Advantages of Managed Code 4 A Closer Look at Intermediate Language 7 Support for Object Orientation and Interfaces 8 Distinct Value and Reference Types 9 Strong Data ...

    php.ini-development

    at runtime. Currently, [PATH=] and [HOST=] sections only work under ; CGI/FastCGI. ; http://php.net/ini.sections ; Directives are specified using the following syntax: ; directive = value ; ...

    spring-boot-reference.pdf

    24.2. Accessing Command Line Properties 24.3. Application Property Files 24.4. Profile-specific Properties 24.5. Placeholders in Properties 24.6. Using YAML Instead of Properties 24.6.1. Loading YAML ...

Global site tag (gtag.js) - Google Analytics