I had a strange problem: if I call getString(R.string.somestringname), from time to time, even after deleting the R file and recompiling, the wrong line appears. The emulator does not crash and the correct line appears - it is simply incorrect.
Sample my .xml lines:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">an app name</string>
<string name="selector_name">app name | Select</string>
<string name="create">Create</string>
<string name="overview_name">appname | Overview</string>
<string name="another_name">appname | Another View</string>
.....
<string name="placeholder">Foo bar</string> <-- here is a problem
<string name="created">Created:</string>
</resources>
Here is a sample code that encounters one of the problems:
if (note.created != null) {
createdtext.setText(getString(R.string.created) + " " + Util.longDateFormat(note.created));
}
The text that is displayed (part of the time) is Foo bar November 03, 2010(i.e. belongs to R.string.placeholder). What's happening? It annoys me when I am tempted by hard-code strings; -)
Thank you for your help!
source
share