一个小工具类
package com.listviewtest;
import android.content.Context;
/**
* 获取资源文件识别码
*/
public class IdentifierUtil {
public static int getIdentifier(Context context, String type, String payId) {
String packageName = context.getPackageName();
return context.getResources().getIdentifier(payId, type, packageName);
}
public static int getDrawableIdentifier(Context context, String payId) {
return getIdentifier(context, "drawable", payId);
}
public static int getStyleIdentifier(Context context, String payId) {
return getIdentifier(context, "style", payId);
}
}