在ViewPager中更新所有其他选项卡

发布于 2025-02-12 18:34:32 字数 562 浏览 0 评论 0原文

我正在使用MVVM体系结构构建TODO列表应用程序。 我有3个选项卡的观点:每日,每周和每月。

当我从每日选项卡中编辑任务并将其保存到数据库时,我可以在“每日”选项卡中看到更新的任务,并且可以很好地工作。

问题是当我转到未更新任务的每周和每月标签时。 当同一天的任务发生更改时,我需要刷新日历。 我正在使用可折叠日历库( https://github.com/github.com/github.com/shrikanth7698/collapsible-calendar -View-android

  • 我考虑过使用接口每当更新任务时,我都可以更新所有其他片段。

  • 我还看到有些人建议在主动行动中做一种方法,并从我需要的任何片段中称呼它,但我不知道这是否是一个好习惯。

您认为解决这个问题的最佳方法是什么?谢谢 !

I am building TODO list app using MVVM architecture.
I have view pager with 3 tabs: Daily, Weekly, and Monthly.

When I edit a task from daily tab and save it to the database,I can see the updated task in the daily tab and it's working perfectly.

The problem is when I move to the Weekly and Monthly tabs ,where the task is not updated.
I need to refresh the calendar when there is a change in the tasks of the same day.
I am using Collapsible Calendar library ( https://github.com/shrikanth7698/Collapsible-Calendar-View-Android )

  • I thought about using interface that whenever a task is updated I can update all the other fragments.

  • I also saw some people suggest making a method in MainActivity and call it from any fragment I need but I don't know if its a good practice.

What do you think is the best approach to this problem? Thank you !

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文