A way to get resources id with good performance.
Not in good performance:
http://developer.android.com/intl/ja/reference/android/content/res/Resources.html#getIdentifier(java.lang.String,%20java.lang.String,%20java.lang.String)
Resources r = getResources();
int drawableId = r.getIdentifier("drawableName", "drawable", "com.mypackage.myapp");
Improve:
http://daniel-codes.blogspot.jp/2009/12/dynamically-retrieving-resources-in.html
try {
Class res = R.drawable.class;
Field field = res.getField("drawableName");
int drawableId = field.getInt(null);
}
catch (Exception e) {
Log.e("MyTag", "Failure to get drawable id.", e);
}