如何获取 CaledarView 当前选择的日期?

发布于 2025-01-15 06:56:05 字数 227 浏览 2 评论 0原文

我正在使用日历视图创建应用程序,我想将当前选定日期的数据存储在变量中。为此,我使用了 OnDateChangeListener。一切正常,但如果我在打开活动时不选择任何其他日期并将日历保留为默认日期(当然它会突出显示我打开应用程序的日期),则变量不会存储任何内容,并且 OnDateChangeListener 不起作用。简而言之,我必须单击日历上的任何日期才能将其保存在变量中。默认情况下突出显示的日期不会存储在变量中。抱歉我的英语不好。

I am creating application with Calendar View and i want to store data of currently selected date in variable. To do that I used OnDateChangeListener. Everything is working but if I don't select any other date when opening activity and leave Calendar on default date (of course it highlights a date on which I am opening the app), variable is storing nothing and OnDateChangeListener is not working. In short I have to click on any date on calendar to save it in variable. Date which is highlighted by default is not getting stored in variable. Sorry for my bad English.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长亭外,古道边 2025-01-22 06:56:05

我创建了简单的 DateFormate 并将其转换为字符串。然后创建 3 个字符串,如年、月和日期,然后我将这 3 个字符串指定为简单 DateFormat 的子字符串。

I created simple DateFormate and converted it into string. Then created 3 strings like year, month and date and then I assigned those 3 strings as substring of simple DateFormat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文