I ma making a game, and I want to pull the apprpriate dialog from the resource file, but which string to pull changes from level to level.
How would I get this to work?
I would want something like:
int level = 3;
String dialog = getResources().getString(R.string.["level_dialog_"+level]);
With the goal being that the apprpriate string resource ID is found using the name of the string resource plus the level. But of course that won’t even compile.
What is the right way to do this?
Thanks AJcodez for getting me thinging along the right path. Even if you answer was not the right one.
I found the right answer myself:
To get a resource by string name, there is already an android function as part of the Resources object:
The first line, I get the resource id. The parameters are the name of the resournce, the type (array, id, string, drawable, etc) and the third parameter is the package name.
In the second line, I can now get the resource just like I would using R.array.
(note to self: RTFM)