Skip to content Skip to sidebar Skip to footer

Retrieving Resource Id From String Value

I know how to retrieve a resID from the name of the string which is present in strings.xml Chennai We can retrieve the resID by fo

Solution 1:

It's not possible as the string values are not required to be unique. Therefore you can't get "the id" back as potentially you could have multiple ids mapping to the same string.

For example:

<string name="text">Chennai</string>
<string name="text2">Chennai</string>
<string name="text3">Chennai</string>

is completely acceptable. How can you get "the id" back for the string "Chennai"?

Solution 2:

try this in your code - R.string.text

Post a Comment for "Retrieving Resource Id From String Value"