将 AM/PM 从字符串设置为时间选择器对话框? [英] Set AM/PM to Time Picker Dialog From String?

查看:30
本文介绍了将 AM/PM 从字符串设置为时间选择器对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 TextView,其中的时间以 10:00 PM 格式显示,当用户点击该视图时,必须将同一时间设置为 TimePicker对话.我可以将 HourMinutes 设置为 Picker,但在 AM/PM 部分.我总是得到AM用户是否设置了AMPM.如何解决?任何帮助表示赞赏.谢谢!

I have a TextView in which a time is being show in the format 10:00 PM When user Click on that View, same time must be set to the TimePicker Dialog. I am able to set the Hour and Minutes to the Picker, but in AM/PM section. I always get AMwhether user has set AM or PM. How can it be solved? any help is appreciated. Thanks!

推荐答案

我遇到过这种类型的类似问题.

I had Face this Type of Similar issue.

这可能是因为您可能已将 hour 元素设置为下面的方式

it May Be because you might have set your hour element as Below Way

hour = String.valueOf(cal.get(Calendar.HOUR));

试试改成

hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));

希望能帮到你.

这篇关于将 AM/PM 从字符串设置为时间选择器对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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