获取其他项目的资源文件

public static int getDrawableIdForIdentifier(Context context, String id) {

try {

Resources res = context.getPackageManager()

.getResourcesForApplication(context.getPackageName());

String identifier = context.getPackageName() + ":drawable/" + id;

int result = res.getIdentifier(identifier, null, context.getPackageName());

return result;

} catch (Exception e) {

}

return 0;

}

public static int getDrawableIdForIdentifier(Context context, String id) {

try {

Resources res = context.getPackageManager()

.getResourcesForApplication(context.getPackageName());

String identifier = context.getPackageName() + ":drawable/" + id;

int result = res.getIdentifier(identifier, null, context.getPackageName());

return result;

} catch (Exception e) {

}

return 0;

}

你可能感兴趣的:(获取其他项目的资源文件)