如何设置从资源的位图位图、如何设置、资源

由网友(Ronin)分享简介:这看起来很简单,我想设置一个位图图像,但是从资源我在绘制文件夹中的应用程序中。This seems simple, i am trying to set a bitmap image but from the resources i have within the application in the drawabl...

这看起来很简单,我想设置一个位图图像,但是从资源我在绘制文件夹中的应用程序中。

This seems simple, i am trying to set a bitmap image but from the resources i have within the application in the drawable folder.

 bm = BitmapFactory.decodeResource(null, R.id.image);

这是正确的?

Is this correct ?

推荐答案

假设你在一个Activity类调用这个

Assuming you are calling this in an Activity class

Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.image);

的第一个参数,资源,是必需的。这是在任何情况下(和子样活性)正常获得。

The first parameter, Resources, is required. It is normally obtainable in any Context (and subclasses like Activity).

阅读全文

相关推荐

最新文章