import java.lang.reflect.Field; import android.content.Context; import android.util.Log; public class ResourceUtil { private static String TAG = "ResourceUtil"; private static ResourceUtil instance; private Context context; private static Class id = null; private static Class drawable = null; private static Class layout = null; private static Class anim = null; private static Class style = null; private static Class string = null; private static Class array = null; private ResourceUtil(Context paramContext) { this.context = paramContext.getApplicationContext(); try { drawable = Class.forName(this.context.getPackageName() + ".R$drawable"); } catch (ClassNotFoundException localClassNotFoundException1) { Log.i(TAG, localClassNotFoundException1.getMessage()); } try { layout = Class.forName(this.context.getPackageName() + ".R$layout"); } catch (ClassNotFoundException localClassNotFoundException2) { Log.i(TAG, localClassNotFoundException2.getMessage()); } try { id = Class.forName(this.context.getPackageName() + ".R$id"); } catch (ClassNotFoundException localClassNotFoundException3) { Log.i(TAG, localClassNotFoundException3.getMessage()); } try { anim = Class.forName(this.context.getPackageName() + ".R$anim"); } catch (ClassNotFoundException localClassNotFoundException4) { Log.i(TAG, localClassNotFoundException4.getMessage()); } try { style = Class.forName(this.context.getPackageName() + ".R$style"); } catch (ClassNotFoundException localClassNotFoundException5) { Log.d(TAG, localClassNotFoundException5.getMessage()); } try { string = Class.forName(this.context.getPackageName() + ".R$string"); } catch (ClassNotFoundException localClassNotFoundException6) { Log.d(TAG, localClassNotFoundException6.getMessage()); } try { array = Class.forName(this.context.getPackageName() + ".R$array"); } catch (ClassNotFoundException localClassNotFoundException7) { Log.d(TAG, localClassNotFoundException7.getMessage()); } } public static ResourceUtil getResofR(Context paramContext) { if (instance == null) instance = new ResourceUtil(paramContext); return instance; } public int getAnim(String paramString) { return getResofR(anim, paramString); } public int getId(String paramString) { return getResofR(id, paramString); } public int getDrawable(String paramString) { return getResofR(drawable, paramString); } public int getLayout(String paramString) { return getResofR(layout, paramString); } public int getStyle(String paramString) { return getResofR(style, paramString); } public int getString(String paramString) { return getResofR(string, paramString); } public int getArray(String paramString) { return getResofR(array, paramString); } private int getResofR(Class<?> paramClass, String paramString) { if (paramClass == null) { throw new IllegalArgumentException("ResClass is not initialized."); } try { Field localField = paramClass.getField(paramString); int k = localField.getInt(paramString); return k; } catch (Exception localException) { localException.printStackTrace(); } return -1; } }
来源:http://my.eoe.cn/119358/archive/552.html
相关推荐
ntfs-3g Android 11 Android R可编译代码。使支持ntfs格式tf卡、U盘、stat硬盘挂载,解压文件到任意可以被编译到的目录下,mm编译成功后,可以编译到/vendor/bin目录下。
像Android R文件一样管理资源.zip,在swift项目中获取强类型、自动完成的资源,如图像、字体和分段
查看android.R.drawable图片。点击并显示出名称 UTF-8 android2.2~android4.2
Android的原始R文件,可以直接查找原引用自原始的视图及图标
收缩器将删除所有r.class和r\$**.class,所有常量整型字段将由asm和transform api内联。
基于机器学习的Android恶意软件检测 Android恶意软件检测使用机器学习是一种检测和分类Android设备恶意应用程序的方法。识别可疑应用程序的一种精确方法是监控android设备所连接的网络。机器学习是人工智能的一个...
Android SDK (SDK Platforms Preview)-android-R.zip
Android 11.0 Preview 4源码,下载文件中有网盘链接及提取码,资源文件已被分卷压缩,文件较大。有问题请私信我
像Android R文件一样管理资源
android RS232串口读写程序,内含jni程序代码,使用android studio打开编译
Android_SDK_R22.6.1Android_SDK_R22.6.1Android_SDK_R22.6.1Android_SDK_R22.6.1
1. 基于Android 11源码编译生成。 2. 文件解压后,点击soong_build.html打开主页面,在该页面可以查到Android.bp使用的各种模块。 3. 该资源脱机使用,不需要联网。 4. 常用模块举例,cc_binary, cc_library, cc_...
本文总共列出了119类恶意软件家族 列表列出了截止日期是2013年2月28日的Android平台上的木马以及在mobile-sandbox-system上的检测结果。这个表会一直更新,每个家族选取一列来做说明
Android 实现了可以滑动左侧边缘退出Activity的功能
Android录屏框架,目的是使用system uid实现(内录)submix的录制
PUSHR - FOR ANDROID Welcome to the Pushr for Android source tree! To build this code, there are a few things you'll need: Java 1.5 or later. The Android SDK. Ant (1.6 ) or Eclipse (3.3 ) A Flickr API...
Android所有系统资源图标android.R.drawable.xxx查看软件 源码地址:http://blog.csdn.net/dianyueneo/article/details/7197067
android.R.styleable 类包含所有组件相关的XML属性。