How to get strings dynamically from strings.xml where
for(int=1; i<100; i++){
String podp = podp+i;
context.getString(R.string.+podp) //here I have to put podp variable
}
I got error identifier expected.
How to get strings dynamically from strings.xml where
for(int=1; i<100; i++){
String podp = podp+i;
context.getString(R.string.+podp) //here I have to put podp variable
}
I got error identifier expected.
You can use this:
public static String getStringByIdName(Context context, String name) {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
}
And call with dynamic name, which will return value inside <string id="podp">...</string>
tag:
String podp = getStringByIdName(this, "podp");