我想處理按鈕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;
}
你所說的壓力是指按鈕onBack?你的意思是當按下後退按鈕時? – 2012-08-13 15:15:42
當我按下智能手機的默認後退按鈕。 – user1480020 2012-08-13 15:17:07