android - R.string not working onCreate() -
i need display 'dynamic text' concatenated 2 r.strings
, 1 string
variable:
the fact need display @ beginning on oncreate()
method, error:
caused by: android.content.res.resources$notfoundexception: string resource id #
this tried do:
text2.settext(r.string.still + playersamount + r.string.lastremaining); //display single
any ideas?
if tell call first 1 phone number, other, can't sum them , call result. you're doing.
r.string.some_id
integer maps string , can localized. localization works mapping same id
different values different languages. can resolved though, if using id
, , that. modifying id lead invalid results: error see.
you need 2 strings seperately.
getstring(r.string.first) + playersamount + getstring(r.string.second)
then normal rules string concatenation apply.
also, should have on string formatters since reduce need manual concatenation, lead problems if ever add multiple languages.
<string name="formatted_string">i have %d players</string>
can used this:
context.getstring(r.string.formatted_string, playersamount);
Comments
Post a Comment