DatePickerDialog.OnDateSetListener没有得到三星的设备回调 [英] DatePickerDialog.OnDateSetListener does not get a callback on Samsung devices

查看:289
本文介绍了DatePickerDialog.OnDateSetListener没有得到三星的设备回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一些奇怪的原因,当我在正按钮单击作为DatePickerDialog的onDateSet方法的一部分作为DateSetListener的部分不被调用的仅在三星设备

For some weird reason, when i click on the positive button as part of the DatePickerDialog, the onDateSet method as part of the DateSetListener does not get invoked ONLY ON SAMSUNG DEVICES.

下面是我在做什么:

DateSetListener _datePickerDialogCallback = new DateSetListener();

DatePickerDialog _datePickerDialog = new DatePickerDialog(context, _datePickerDialogCallback, year, month, days);
_datePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE, StringUtil.getString(R.string.command_ok), new DialogInterface.OnClickListener() {

    public void onClick(DialogInterface arg0, int arg1) {
      _done = true;
    }

  });

_datePickerDialog.show();



private class DateSetListener implements DatePickerDialog.OnDateSetListener {

  public void onDateSet(DatePicker view, int year, int month, int day) {

    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, day, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE),
        calendar.get(Calendar.SECOND));

    if (_done) {
      _view.setText(formatDate(calendar.getTime()));
    }
  }
}

为什么这可能发生的是AP preciated任何建议。请。注意,这仅适用于的三星设备

推荐答案

它看起来像来自ICS以上,回调不必在定义datePickerDialog定义。但是,在onPositiveButtonClick和onNegativeButtonClick将不得不调用回调。
是这样的:

It looks like from ICS and above, the callback need not be defined while defining the datePickerDialog. But, the onPositiveButtonClick and onNegativeButtonClick would have to call the callback. something like :

    _datePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {

      public void onClick(DialogInterface arg0, int arg1) {
        _done = true;
        DatePicker datePicker = _datePickerDialog.getDatePicker();
        _datePickerDialogCallback.onDateSet(datePicker, datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth());
      }

    });

这篇关于DatePickerDialog.OnDateSetListener没有得到三星的设备回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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