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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -