Android で strings.xml に定義したテキストを取得するなら、通常以下のような感じになります。
getString(R.string.msg_xxxx);
この msg_xxxx を文字列として指定して動的に取得したいときは以下のような感じです。
public static String getByName(Context context, String key) {
int strId = context.getResources().getIdentifier(key, "string", context.getPackageName());
if (strId <= 0) {
return "";
}
return res.getString(strId);
}
Activity で呼ぶなら以下のようになります。
Xxxx.getByName(this, "msg_xxxx");