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());
}
}

ResourceUtils 创建资源目录工具类的更多相关文章

  1. 获取全局上下文(getApplicationContext)_创建Shared Preference工具类_实现自动登录

    获取全局上下文(getApplicationContext)_创建Shared Preference工具类_实现自动登录 ===========================获取全局上下文(getA ...

  2. 编写Java程序,创建一个数学工具类,将该类设计为final类,Final 修饰符的使用。

    返回本章节 返回作业目录 需求说明: 创建一个数学工具类. 将该类设计为final类. 将该类的构造方法的访问权限定义为私有,以防止外界实例化该类. 在该类定义静态double类型常量π,其值为3.1 ...

  3. 创建Jdbc封装工具类

    jdbc.propertie url=jdbc:mysql:///empye user=root password=root driver=com.mysql.jdbc.Driver 读取资源文件  ...

  4. Android中创建倒影效果的工具类

                     一.有时候我们需要创建倒影的效果,我们接触最多的都是图片能够创建倒影,而布局依然可以创建倒影.       二.工具类代码 import android.graphi ...

  5. **CI创建类库(创建自己的工具类等)

    创建类库 当我们使用术语"类库"时,我们一般指的是位于libraries 文件夹中的类,它们在wiki的"类库参考"这个板块被讨论.在当前这个话题中,我们将讨论 ...

  6. 使用JFreeChart创建柱状图的工具类

    package cn.xfz.oa.util; import java.awt.Font; import java.util.List; import org.jfree.chart.ChartFac ...

  7. java关闭资源,自制关闭资源工具类

    在网上看到一篇关于关闭资源的正确方式:http://blog.csdn.net/bornforit/article/details/6896775 该博文中的总结: (1)使用finally块来关闭物 ...

  8. QMUI UI库 控件 弹窗 列表 工具类 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  9. hibernate工具类

    因为hibernate的代码大部分都是固定的,为了将减少重复的代码的书写,可以将这些代码封装为一个工具类,获取hibernate的session对象. 1.工具类: package pers.zhb. ...

随机推荐

  1. 处理Android键盘覆盖input和textarea框的问题

    $(window).resize(function(){ $('input[type="text"],textarea').on('click', function () { va ...

  2. springboot2集成activiti出错

    报一个反射错误 java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy 解决方案:http ...

  3. Spring-简介-IOC理论推导

    1.Spring 1.1.简介 Spring:春天----->给软件行业带来了春天! 2002,首次推出了Spring框架的雏形:interface21框架! Spring框架即以interfa ...

  4. 解决安卓app在真机上的无法登录问题

    和小伙伴用安卓做的app在模拟器上可以正常使用,但是变成apk发到手机上下载使用时,出现无法的登录问题,而且登录提示的错误出现一秒就消失了,无法看清. 于是找了一下老师帮忙,老师是通过在电脑主机上插入 ...

  5. C语言Ⅰ作业-05

    这个作业属于哪个课程 C语言程序设计Ⅰ 这个作业要求在哪里 https://www.cnblogs.com/tongyingjun/p/11722665.html 我在这个课程的目标是 熟练掌握如何用 ...

  6. BZOJ 1027: [JSOI2007]合金 (计算几何+Floyd求最小环)

    题解就看这位仁兄的吧-不过代码还是别看他的了- 同样的方法-我200ms,他2000ms. 常数的幽怨- CODE #include <bits/stdc++.h> using names ...

  7. redis序列化和反序列化

    RedisTemplate中需要声明4种serializer,默认为“JdkSerializationRedisSerializer”: 1) keySerializer :对于普通K-V操作时,ke ...

  8. Python2.x与3​​.x版本区别Ⅲ

    八进制字面量表示 八进制数必须写成0o777,原来的形式0777不能用了:二进制必须写成0b111. 新增了一个bin()函数用于将一个整https://www.xuanhe.net/数转换成二进制字 ...

  9. PHP mysqli_fetch_assoc() 函数

    从结果集中取得一行作为关联数组: <?php // 假定数据库用户名:root,密码:123456,数据库:RUNOOB $con=mysqli_connect("localhost& ...

  10. 关于JPA动态SQL查询

    1.继承接口 2.下面是简单的操作---自己写过的,下次再整理一下 public Page<IdddsMember> list(MemberSearch search, Pageable ...