我正在做一个小游戏,我试图表现出的AlertDialog,问题是,当用户点击一个选项AlertDialog不会dissapear。AlertDialog不解雇
我正在使用loopers,所以我的游戏线程在我的AlertDialog出现时停止(looper),当用户单击“取消”时游戏线程再次运行,但对话框在顶部,用户无法保持播放。
public void alerta(){
Looper.prepare();
myHandler = new Handler();
AlertDialog.Builder alertadd = new AlertDialog.Builder(_context);
LayoutInflater factory = LayoutInflater.from(_context);
final View view = factory.inflate(R.layout.custom_dialog, null);
alertadd.setView(view);
alertadd.setNeutralButton("Tomar Foto", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
stops++;
Toast.makeText(_context.getApplicationContext(), "Tomaste Foto", Toast.LENGTH_SHORT).show();
}
});
alertadd.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
System.out.println("Stops = "+stops);
stops++;
Toast.makeText(_context.getApplicationContext(), "Cancelar", Toast.LENGTH_SHORT).show();
myHandler.getLooper().quit();
dlg.dismiss();
}
});
alertadd.show();
Looper.loop();
}
还是同样的问题,感谢您试用 – user1364649
我敢肯定这工作,但我认为我的问题是与我的looper – user1364649