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. OpenCV入门学习资料汇总

    OpenCV学习文档资料 OpenCV学习:1)OpenCV中文网站——http://wiki.opencv.org.cn/index.php/%E9%A6%96%E9%A1%B5 2)python实 ...

  2. 关于网站子目录绑定二级域名的方法(php网站手机端)

    最近帮客户做zencart网站手机模板用到了二级域名,通过判断手机访问来调用二级目录程序,http://afish.cnblogs.com/ 怎么说都比 http://www.cnblogs.com/ ...

  3. 【经典dp 技巧】8.13序列

    经典的拆绝对值 题目大意 给定$n$个具有顺序的序列,允许对每个序列循环移动.记第$i$个序列尾元素为$x$,$i+1$个序列首元素为$y$,定义其连接收益为$|x-y|*i$,求$n$个序列连接最大 ...

  4. Java实现从服务器下载文件到本地的工具类

    话不多说,直接上代码...... import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServlet ...

  5. PHP流协议

    目前对PHP流协议的定义是数据传输过程中,不同数据类型采用不同处理函数的技术规范(个人理解)这一规范比起传统文件处理函数来的更规范(诸如fget,fwrite,fopen,fclose等) $opts ...

  6. sql防止注入的技巧

    from Stack Overflow Here is a similar solution which I think is more efficient in building up the li ...

  7. C# Tcp和Socket 网络(五)

    TcpReceive public Form1() { InitializeComponent(); new Thread(() => { IPAddress ip = IPAddress.Pa ...

  8. Java实现浏览器大文件分片上传

     上周遇到这样一个问题,客户上传高清视频(1G以上)的时候上传失败. 一开始以为是session过期或者文件大小受系统限制,导致的错误. 查看了系统的配置文件没有看到文件大小限制, web.xml中s ...

  9. 简易的学生成绩管理系统(C++实现)

    最近浅显的学习了C++的基础知识,想来练练手,于是就用单链表写了最经典的小项目,存粹学习,所以就在控制台下写了,写的有点简陋,码了大概400多行. 下面上代码: #include <cstdli ...

  10. python 获取数字在内存的内容

    #coding=utf- from struct import pack,unpack byte=pack('f',1.5) print(byte) print([i for i in byte]) ...