Browse » Home » Resource, Tips » Blog article: 通过Resoruce的Name得到其标识符(Identifier)

利用几句简单的语句可以根据Resource的displayName获得系统中唯一的标识符,程序可以通过标识符获得Resource。
源代码:

   1. int drawable_id = context.getResources().getIdentifier("ball_red", "drawable", context.getPackageName());

文章来源 Androidsnippets.org

Tags: ,

Posted in Resource, Tips |

Random Posts



Leave a Reply

You must be logged in to post a comment.