如何解决TimePickerDialog 在关闭时打开键盘
TimePickerDialog
正在从对话框中选择一段时间后打开软键盘。
当 TimePickerDialog
处于键盘形式时,我能够关闭键盘,但当对话框在 12/24 小时时钟视图中结束时,似乎没有任何东西使键盘消失。
有什么建议吗?谢谢。
我的代码:
// Set the onClick listener to bring up a TimePickerDialog and set the time
v.findViewById(R.id.nrtp_time_field).setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TimePickerDialog tpg = new TimePickerDialog(c,new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker,int hour,int minute) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY,hour);
cal.set(Calendar.MINUTE,minute);
setTime(cal);
if (isTime) {
timeView.setText(getStrTime());
}
if (isDuration) {
timeView.setText(getStrDuration());
}
timeView.clearFocus();
}
},currentHour,currentMinute,use24HourFormat);
tpg.setondismissListener(new DialogInterface.OndismissListener() {
@Override
public void ondismiss(DialogInterface dialog) {
// dismisses the keyboard. Only works for keyboard version,not clock view
InputMethodManager inputMethodManager = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY,0);
}
});
tpg.show();
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。