我目前正在开发android,遇到了一个非常严重的问题:
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Log.i("GAME", "onDraw Called");
for(int i = 0; i < totalEggNumbers -1; i++) {
if (egg[i].isKilled = false)
canvas.drawBitmap(image[egg[i].getEggNum()], egg[i].getX(), egg[i].getY() + 100, paint);
Log.i("GAME", "Something Drawn");
}
}
// called by thread
public void update() {
//Chance to make egg
Log.i("GAME", "Updated Game");
eggMaker.randomEgg(difficulty);
postInvalidate();
}在我终止应用程序后,onDraw永远不会被调用,我在logcat中找不到日志,但当它运行时,我可以看到一个"onDraw cant“偶尔出现和消失。
我真的很绝望..。我正在使用android view btw。有没有办法调用onDraw方法?我尝试过invalidate();,但没有机会,请修改我的代码:)
发布于 2012-08-14 02:52:27
在将图像传递给drawBitMap方法之前,请尝试将其作为BitMap对象
Bitmap bmp = BitmapFactory.decodeResource(
getResources(), image[egg[i].getEggNum());https://stackoverflow.com/questions/11940149
复制相似问题