1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
public class ResourcesUtils { private static final String RES_ID = "id"; private static final String RES_STRING = "string"; private static final String RES_DRABLE = "drable"; private static final String RES_LAYOUT = "layout"; private static final String RES_STYLE = "style"; private static final String RES_COLOR = "color"; private static final String RES_DIMEN = "dimen"; private static final String RES_ANIM = "anim"; private static final String RES_MENU = "menu";
public static int getId(Context context,String resName){ return getResId(context,resName,RES_ID); }
public static int getStringId(Context context,String resName){ return getResId(context,resName,RES_STRING); }
public static int getDrableId(Context context,String resName){ return getResId(context,resName,RES_DRABLE); }
public static int getLayoutId(Context context,String resName){ return getResId(context,resName,RES_LAYOUT); }
public static int getStyleId(Context context,String resName){ return getResId(context,resName,RES_STYLE); }
public static int getColorId(Context context,String resName){ return getResId(context,resName,RES_COLOR); }
public static int getDimenId(Context context,String resName){ return getResId(context,resName,RES_DIMEN); }
public static int getAnimId(Context context,String resName){ return getResId(context,resName,RES_ANIM); }
public static int getMenuId(Context context,String resName){ return getResId(context,resName,RES_MENU); }
public static int getResId(Context context,String resName,String defType){ return context.getResources().getIdentifier(resName, defType, context.getPackageName()); } }
|