如何将图片资源转为整型? 我用过这个:
int rh=this.getResources().getIdentifier("ic_launcher", null, this.getPackageName());
但它不会工作。 我对此进行了记录,并且 rh 的值始终为 0。 有没有其他方法可以将图像转换为整数?
最佳答案
试试这个指定类型:
int rh=this.getResources().getIdentifier("ic_launcher", "drawable", this.getPackageName());
请记住,它不是将图像转换为整数,getIdentifier()
仅查找资源 ID,该 ID 用于查找打包在 .apk 文件中的资源。
关于android - 图像到整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8150800/