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

Say I have an xml file called test1.xml in the format String xmlFile = "test1.xml". How can I get the value of R.id.test1?

+3
source share
1 answer

I think you need a method getIdentifier (String name, String defType, String defPackage)in the class Resources. Here is the documentation .

However, this approach is rather slow; pay attention to the following documents:

Note: Using this feature is not recommended. It is much more efficient to retrieve resources by identifier than by name.

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

+3
source

Source: https://habr.com/ru/post/1771549/


All Articles