I am trying to reference a string stored in a .xml file, and every time i reference it I just get a string of numbers.
if (Medals.medal_counter1 == 0) {
Medals.medal_counter1++;
victory.setMessage("you won " + R.string.medal01);
}
victory.show();
Here is the stored string.
<string name="medal01">"A medal"</string>
The dialog I actually get is something more like this,
“you won 21310334567”
Any solutions?
That’s because you are getting the string resource’s ID. If you want to retrieve the actual string content you need to use
Context.getString(int resourceId)method.For instance, from inside an Activity:
Otherwise: