几个片段需要位置更新(Several fragments need location updates)

系统教程 行业动态 更新时间:2024-06-14 17:03:52
几个片段需要位置更新(Several fragments need location updates)

我正在搞乱一个由两个片段组成的应用程序,每个片段都在自己的标签中。 一个是listfragment,另一个是mapfragment。 两个片段都需要位置更新作为位置更改。

我正在读这个教程。

我想知道我是否应该在主机活动上实现这一点,并在位置更新时将位置传递给每个片段。 但我不确定如何解决这个问题。 因为listfragment需要将它传递给与该类关联的加载器。

或者为每个片段实现回调,并可能将ErrorDialogFragment和servicesConnected作为宿主类的成员保留? 甚至在单独的课堂上? 避免重复的代码。

你们有什么感想?

I'm messing around with an app which consists of two fragments, each in their own tab. One is a listfragment and the other is a mapfragment. Both fragments need location updates as location changes.

I'm reading this tutorial.

I'm wondering if I should implement this on the host activity and pass on the location to each fragment as the location updates. But I'm unsure about how to go about this. Because the listfragment would need to pass it on to the loader associated with the class.

Or implement the callbacks for each fragment and possible keep ErrorDialogFragment and servicesConnected as members of the host class? Or even in separate class? To avoid duplicated code.

What do you guys think?

更多推荐

本文发布于:2023-04-24 12:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/bc5cbad5bcd72c451f6397f15ed939ce.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几个   片段   位置   updates   location

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!