我想处理按钮onBack
,当它被按下时,会AlertDialog
出现一个,以便 onBack 按钮的压力,你将一个变量设置为-1。
这是我的警报对话框的代码:
protected Dialog onCreateDialog(int id)
{
switch(id)
{
case CUSTOM_DIALOG:
AlertDialog.Builder builder1;
builder1 = new AlertDialog.Builder(SecondaAttivita.this);
builder1.setView(layout);
builder1.setCancelable(true);
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(testo.getWindowToken(), 0);
testo.setInputType(0);
alertDialog1 = builder1.create();
break;
default:
alertDialog1.dismiss();
alertDialog1 = null;
}
return alertDialog1;
}