android - get string from Strings.xml by a variable -


i want string strings.xml. know how this. problem else: have string variable changes every time, , every time changes, want @ strings.xml , check if string variable exists in strings.xml, text.

for example:

string title="sample title" \\ changes string city= "sample city" string s = getresources().getstring(r.string.title); 

in third line: title string, , there isn't "title" named string in strings.xml how can this? please me

as far can tell, use public int getidentifier (string name, string deftype, string defpackage). use discouraged, though.

to use (i haven't done had once read method) need to:

int identifier = getresources().getidentifier ("title","string","your.package.name.here"); if (identifier!=0){      s=getresources().getstring(identifier); } else{     s="";//or null or whatever } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -