开发者

Android SDK - get R.id (int) of a string value

Lets say I have an xml file 开发者_如何学Pythoncalled test1.xml in String xmlFile = "test1.xml" format. How can I get the R.id.test1 value of it?


I think you want the getIdentifier (String name, String defType, String defPackage) method within the Resources class. Here is the documentation.

However this approach is quite slow, note the following from the docs:

Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.

Here is another similar question: get resource id by passing name as a parameter in android

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜