动态改变ResId
public static int getResId(String variableName, Class<?> c) {
try {
Field idField = c.getDeclaredField(variableName);
return idField.getInt(idField);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
使用方法
int id = ResourceMan.getResId("icon", R.drawable.class);
原始链接:
根据字符串获取资源id