如何检测取消点击日期选择器对话框的? [英] How do I detect a cancel click of the datepicker dialog?

查看:158
本文介绍了如何检测取消点击日期选择器对话框的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下 例如日期选择器

i am using following example of date picker

<一个href="http://developer.android.com/guide/tutorials/views/hello-datepicker.html">http://developer.android.com/guide/tutorials/views/hello-datepicker.html

现在我想在点击日期选择取消按钮,但没有看到取消事件中datepickerdialog执行一些功能

now i want to perform some functionality on clicking date picker cancel button but dont see cancel event inside datepickerdialog

任何一个可以指导我如何做到这一点。

can any one guide me how to achieve this.

任何帮助将是AP preciated。

any help would be appreciated.

推荐答案

下面是我如何做的:

  DatePickerDialog dialog = new DatePickerDialog(this,
              mDateSetListener,
              year, month, day);

  dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
       if (which == DialogInterface.BUTTON_NEGATIVE) {
          // Do Stuff
       }
    }
  });

这篇关于如何检测取消点击日期选择器对话框的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆