• ResourceUtils 创建资源目录工具类


    package com.jcf.utilsdemo;
    
    import android.content.Context;
    import android.content.res.Resources;
    
    public class ResourceUtils {
    
       public static int getDrawableId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "drawable", context.getPackageName());
       }
    
       public static int getLayoutId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "layout", context.getPackageName());
       }
    
       public static int getStringsId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "string", context.getPackageName());
       }
    
       public static int getColorId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "color", context.getPackageName());
       }
    
       public static int getIdId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "id", context.getPackageName());
       }
    
       public static int getRawId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "raw", context.getPackageName());
       }
    
       public static int getAnimId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "anim", context.getPackageName());
       }
    
       public static int getStyleId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "style", context.getPackageName());
       }
    
       public static int getStyleableId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "styleable", context.getPackageName());
       }
    
       public static int getAttrId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "attr", context.getPackageName());
       }
    
       public static int getArrayId(Context context, String name) {
          Resources res = context.getResources();
          return res.getIdentifier(name, "array", context.getPackageName());
       }
    }
    
  • 相关阅读:
    索引信息统计
    删除脚本
    归档脚本
    SQL2005四个排名函数(row_number、rank、dense_rank和ntile)的比较
    用js输出同样字符出现的次数
    grid布局
    统计字符出现的次数
    百度地图
    For each...in,For...in ,For...of的Examples和Explanation
    Object的起源
  • 原文地址:https://www.cnblogs.com/loaderman/p/6435154.html
Copyright © 2020-2023  润新知