What I want to do is to get a specific text from strings.xml dynamically. I think it will involve to access an object variable dynamically.
There will be a function like:
public void getDynamicString(int level) {
text.setText(R.string.levelText_+level);
}
And in strings.xml there will be <string name="levelText_5">Text level 5</string>
I would rather not create a list with all the text resources. Can one do this in Java/Android.
Use the method
getIdentifier(name, defType, defPackage)of the Resources class to get the id of a resource by name. Then you can do a normalgetString(id)from the same class.EDIT: a bit of Googling revealed this: this. You can find sample usage there.