可以使用BitmapFactory.decodeResource(context,int)获取上下文字符串

时间:2011-01-24 16:32:04

标签: android image resources bitmapfactory

我有一个方法返回一个String(让我们说var精灵),这个字符串是我的位图img的名称,我想用它与BitmapFactory.decodeResource(),但我不知道如何结合因为它必须是int R.drawable.sprite

可以这样做吗?

1 个答案:

答案 0 :(得分:2)

是的,这是可能的。看看这个问题:

Android and getting a view with id cast as a string