开发者

AlertDialog negative button is not handled

I have an alert dialog with 2 buttons, positive an negative. Positive button's handler works as it should be, but negative button click doesn't invoke its handler. Doee anybody know what's wrong here? Thank you.

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;
}


You probably need to dismiss or cancel dialog as well.


Sorry guys, break point was set at "Editor prefEditor = PreferenceManager." line, because line breaks eclipse didn't stop at that line. Break point at next line worked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜