2011-05-16 50 views
0

我有一个警告对话框2个按钮,积极负面。 正面按钮的处理程序按原样工作,但负面按钮点击不会调用其处理程序。 Doee有人知道这里有什么问题吗?谢谢。AlertDialog负面按钮不处理

protected Dialog onCreateDialog(int id) 
{ 
    switch (id) 
    { 
     case DOWNLOAD_DIALOG_ID: 
      return new AlertDialog.Builder(this) 
       .setIcon(R.drawable.alert_dialog_icon) 
       .setTitle(R.string.download_videos_title_msg) 
       .setMessage(R.string.download_videos_main_msg) 
       .setPositiveButton(R.string.download_videos_download_btn, 
        _downloadVideoContent) 
       .setNegativeButton(R.string.download_videos_ask_later_btn, 
        new DialogInterface.OnClickListener() { 
         @Override 
         public void onClick(DialogInterface dialog, int id) 
         { 
          Editor prefEditor = PreferenceManager. 
           getDefaultSharedPreferences(_context).edit(); 
          prefEditor.putBoolean(DOWNLOAD_DECLINED_FLAG, true); 
          prefEditor.commit(); 
         } 
       }) 
       //.setNegativeButton(R.string.download_videos_ask_later_btn, 
       // _cancelDialogListener) 
       .create(); 
    } 
    return null; 
} 

回答

0

对不起, 中断点被设置为“Editor prefEditor = PreferenceManager”。因为换行符eclipse并没有停在那一行。下一行的断点工作。

+0

代码是否正确 – Maxim 2011-06-22 19:24:15

0

您可能需要关闭或取消对话框。