我有Dialog
透明活动,它就像一个暂停菜单,所以当显示对话框并按下Home
按钮时一切正常,但是当我重新打开它时,它Dialog
显示,除了背景是空白的。游戏是用做的canvas
,SurfaceView
所以我不能 Dialog
在那个屏幕上显示,或者我可以,因为我在尝试,但每次都会出错
所以当我按下返回键时Dialog
显示完美:
但是当我单击主页按钮并长时间单击主页按钮以重新打开应用程序时,我得到了这个:
onResume 代码:
@Override
protected void onResume() {
super.onResume();
ourSurfaceView.resume();
}
public void resume() {
isRunning = true;
ourThread = new Thread(this);
ourThread.start();
}
活动显示Dialog
:
public class ShowPopUp extends Activity {
Dialog myDialog;
GameSurface ourSurfaceView;
Button toMenu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showpopupmain);
myDialog = new Dialog(ShowPopUp.this);
myDialog.setContentView(R.layout.showpopup);
myDialog.setTitle("Paused");
myDialog.setCancelable(true);
Button button = (Button) myDialog.findViewById(R.id.Btn1);
toMenu = (Button)myDialog.findViewById(R.id.Btn2);
toMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
Intent menu = new Intent(
"com.example.mygame.Menu");
startActivityForResult(menu, 5);
}
});
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myDialog.dismiss();
finish();
}
});
myDialog.show();
myDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
ShowPopUp.this.finish();
}
});
}
}