Issue
How to add string in int?
R.string.name+Integer.parse(myindex).
not working.Link txtt.setText(getString(R.string.("i" + j++))); not helpful. others found
Solution
you can use getIdentifier() to retrieve the string's id, it returns a resource identifier for the given resource name.
int stringId = getResources().getIdentifier("name"+myIndex, "string", getPackageName());
if (stringId > 0) {
textView.setText(stringId);
}
if you are looking for a String array, the syntax is slightly different:
int stringId = getResources().getIdentifier("name"+myIndex, "array", getPackageName());
String[] array = getResources().getStringArray( stringId );
Answered By - Blackbelt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.