当今年已通过打字改变的Andr​​oid的DatePicker不承认 [英] Android DatePicker doesn't recognize when the year has been changed via typing

查看:101
本文介绍了当今年已通过打字改变的Andr​​oid的DatePicker不承认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datepicker预期EXCEPT其中工程pretty多少,而不是使用+/-按钮,用户类型的字段时。在这一点上,即使它显示键入的值,它的干将正在返回的任何日期是在那里用户打字之前的信息。一旦用户点击一个+或 - 它更新

I have a DatePicker which works pretty much as expected EXCEPT when instead of using the +/- buttons, the user types in the fields. At that point, even though it's showing the values typed, it's getters are returning the info for whatever date was in there before the user was typing. As soon as the user hits a + or - it updates.

我看到取值,这不是我想要的更新方法。我想招惹它,当用户点击继续按钮(不涉及的DatePicker)重新审视自己的价值观。我可以侦听器连接到焦点的损失,但我看不出有什么我可以打电话得到它重新审视其内容。

I see an update method that takes values, which is not what I want. I want to provoke it to re-examine its values when the user clicks on a "proceed" button (not related to the DatePicker). I can attach a listener to the loss of focus, but I don't see what I can call to get it to re-examine its contents.

所有的想法表示欢迎。

修改
只要用户将焦点移动从整个对象或者离开或甚至三个场之间的的DatePicker绝对更新其值。这个问题,我想,是如何强制焦点远离它,当没有其他任何可以采取集中在屏幕上。我想我的重点继续按钮,但它拒绝接受焦点的某些原因。很想知道更多关于为好,如果有人知道了。

EDIT The DatePicker definitely updates its values as soon as the user moves focus either away from the entire Object or even between the three fields. The question, I guess, is how to force the focus away from it, when there isn't anything else on the screen that can take focus. I'm trying to focus my proceed button, but it refuses to take focus for some reason. Would love to know more about that as well, if anyone knows.

推荐答案

刚需clearFocus上的DatePicker。无需隐藏字段。

Just need to clearFocus on DatePicker. No need for hidden field.

final DatePicker dp = (DatePicker)v.findViewById(R.id.dpDate);

dlg.setPositiveButton("Done", new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int id) {
      dp.clearFocus();
      String val = "";
      int m = dp.getMonth() + 1;
      val = m + "/" + dp.getDayOfMonth() + "/" + dp.getYear();
      mA.setmDOB(val);
      etAge.setText(AppHelper.calcAge(val, "y", false) + "  (" + val + ")");
 }
 });

这篇关于当今年已通过打字改变的Andr​​oid的DatePicker不承认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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