我使用以下代码绘制画布的背景图像... 但是没有绘制图像..它显示非法状态异常..任何解决方案请... 提前谢谢。
代码段
public MyView(Context c) {
super(c);
//mBitmap = Bitmap.createBitmap(320, 480, Bitmap.Config.ARGB_8888);
backgroundBitmap=Bitmap.createBitmap(320,480,Config.ARGB_8888);
// mCanvas = new Canvas(mBitmap);
backgroundBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.background);
mPath = new Path();
mCanvas = new Canvas(backgroundBitmap);
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}
@Override
protected void onDraw(Canvas canvas) {
// canvas.drawColor(0xFFAAAAAA);
// canvas.drawBitmap(mBitmap,0,0, mBitmapPaint);
canvas.drawBitmap(backgroundBitmap, 0, 0, mBitmapPaint);
if(item_id==3) {
canvas.drawText(AppModel.contents, 100, 100, mPaint);
}
else {
canvas.drawPath(mPath, mPaint);
}
}