`
snrqtdhuqf
  • 浏览: 77252 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

android通过图片名称获取资源识别码

 
阅读更多

一个小工具类

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

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics