我正在搞乱一个由两个片段组成的应用程序,每个片段都在自己的标签中。 一个是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?
更多推荐
发布评论