我是通过在表面视图中使用可运行线程来播放动画。当我第一次运行应用程序时,一切正常,动画播放正常。当我按回/主按钮并重新打开应用程序时,我得到一个没有动画的黑色屏幕,但是可运行的线程在我使用Log cat条目确认的背景上工作。
另外,我正在重写back按钮按事件,finish()在back按钮按下事件中被调用。
有谁能帮我弄清楚为什么在我恢复应用程序时不调用表面处理方法?
注:当我使用时
android.os.Process.killProcess(android.os.Process.myPid());在back按钮事件(而不是finish()方法)中,应用程序在onresume事件中正常工作。
提前谢谢你,蒂姆
发布于 2012-07-26 08:25:20
我认为,您必须扩展SurfaceView类并侦听surfaceChanged方法。并在方法上再画一次。代码:
class MySurfaceView extends SurfaceView implements SurfaceHolder.Callback{
SurfaceHolder holder;
public MySurfaceView(Context context) {
super(context);
holder = this.getHolder();
holder.addCallback(this);
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
//when surfaceChanged,i think you must make your view draw one time.
}
public void surfaceCreated(SurfaceHolder holder) {
//surfaceCreated
}
public void surfaceDestroyed(SurfaceHolder holder) {
//surfaceDestroyed
}
} 希望这能帮到你。
https://stackoverflow.com/questions/11648291
复制相似问题