Java Android位映射

Java Android位映射,java,android,Java,Android,我目前正在学习android位映射,我有一个和图像,我要加载两次,但应用程序崩溃了,我不知道我的问题是什么。 我已经仔细检查了图像的名称和位置,这应该不是我的问题。 任何建议都是有用的 这是我的密码 public class BitmapTest extends Activity { class RenderView extends View { Bitmap bob565; Bitmap bob4444; Rect dst = new Rect(); pu

我目前正在学习android位映射,我有一个和图像,我要加载两次,但应用程序崩溃了,我不知道我的问题是什么。
我已经仔细检查了图像的名称和位置,这应该不是我的问题。
任何建议都是有用的

这是我的密码

public class BitmapTest extends Activity {

class RenderView extends View {

    Bitmap bob565;
    Bitmap bob4444;
    Rect dst = new Rect();

    public RenderView(Context context) {
        super(context);

        try {

            AssetManager assetManager = context.getAssets();
            InputStream inputStream = assetManager.open("bob.png");
            bob565 = BitmapFactory.decodeStream(inputStream);
            inputStream.close();
            Log.d("Bitmap Test", "bob.png format:"+ bob565.getConfig());

            inputStream = assetManager.open("bob.png");
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inPreferredConfig = Bitmap.Config.ARGB_4444;
            bob4444 = BitmapFactory
                    .decodeStream(inputStream  , null , options);
            inputStream.close();
            Log.d("Bitmap test", "bob.png format:" + bob4444.getConfig());
        }catch(IOException e){
            //silently ignored
        }finally{
            // close streams
        }
    } 

    @Override
        protected void onDraw(Canvas canvas){
            canvas.drawRGB(0,0,0);
            dst.set(50,50,350,350);
            canvas.drawBitmap(bob565,null,dst,null);
            canvas.drawBitmap(bob4444,100,100,null);
            invalidate();
        }
    }
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
     requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(new RenderView(this));
}


}

如果您需要有关正在崩溃的应用程序的帮助,则必须从logcat发布崩溃的堆栈跟踪。虽然对这一点稍加研究可能会让你自己找到问题所在。我尝试了你的代码,它与我一起工作。好的,检查你是否在资产文件夹中有名为bob.png的图像,它可能不存在。你真的想在每次绘制视图时使其无效吗?