在ViewPager中更新所有其他选项卡
我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论