关于从mipmap文件夹获取位图时的错误

时间:2015-10-07 04:32:54

标签: android

我在我的visual studio中包含了demo项目。但它在以下陈述中向我显示错误。我也将图像和过去复制到了mipmap中。 请,任何人都可以检查一下是什么错误并指导我。提前谢谢。

  Bitmap fuelbar= BitmapFactory.decodeResource(getResources(), );//Bitmap image gets the fuel image from the resources folder
    Bitmap blastCraft = BitmapFactory.decodeResource(getResources(), R.drawable.explosion);//Bitmap image gets the explosion image from the resources folder
   Bitmap thruster = BitmapFactory.decodeResource(getResources(), R.drawable.thruster);//Bitmap image gets the small thruster image from the resources folder
        Bitmap main_flame = BitmapFactory.decodeResource(getResources(), R.drawable.main_flame);//Bitmap image gets the main flame image from the resources folder

1 个答案:

答案 0 :(得分:3)

您放置位图的文件夹是什么? drawable或mipmap或两者兼而有之?

如果您放入mipmap文件夹,则应将代码更改为:

Bitmap blastCraft = BitmapFactory.decodeResource(getResources(), R.mipmap.explosion);//Bitmap image gets the explosion image from the resources folder
Bitmap thruster = BitmapFactory.decodeResource(getResources(), R.mipmap.thruster);//Bitmap image gets the small thruster image from the resources folder
Bitmap main_flame = BitmapFactory.decodeResource(getResources(), R.mipmap.main_flame);//Bitmap image gets the main flame image from the resources folder