android通过图片名称获取资源识别码
16lz
2021-01-23
一个小工具类
package com.listviewtest;import android.content.Context;/** * 获取资源文件识别码 */public class IdentifierUtil {public static int getIdentifier(Context context, String type, String payId) {String packageName = context.getPackageName();return context.getResources().getIdentifier(payId, type, packageName);}public static int getDrawableIdentifier(Context context, String payId) {return getIdentifier(context, "drawable", payId);}public static int getStyleIdentifier(Context context, String payId) {return getIdentifier(context, "style", payId);}}
更多相关文章
- android实现文件读写功能
- Android 本地文件上传到服务器
- android--------根据文件路径加载指定文件
- android用于打开各种文件的intent,包括以下文件PDF,PPT,WORD,EXC
- android 删除sdcard中文件命令
- android 不能安装超过600MB文件?
- [android]寫一個system/bin 下的可執行文件