Android ActionBar 选项卡 - ListFragment 问题
我有一个有两个选项卡的应用程序。这两个都是ListFragment。 第一个 Tab 使用 CursorLoader 将数据绑定到列表,数据来自 Service。 到目前为止,第二个选项卡中什么也没有,它只是一个空白的 ListFragment。
现在,当我启动应用程序并且服务检索信息时,一切都很好! ListFragment 已填充数据,一切正常。 当我切换到第二个选项卡时,我只能看到一个加载轮,这很好。
当我切换回第一个选项卡时,问题就出现了。当服务启动并开始拉取数据时,我可以看到它在我的日志中拉取数据,但我的 ListFragment 中什么也没有出现。它只是空白,就像 CursorLoader 不再附加一样。
下一个奇怪的事情是,当我关闭应用程序并重新启动它时,数据突然出现在列表中!但是切换的时候又出现了这个bug。
对此有什么想法吗?真是烦死我了!
I have an application which has two Tabs. Both of these are ListFragments.
The first Tab uses a CursorLoader to bind the data to the list, the data comes from a Service.
The second Tab has nothing in it so far, its just a blank ListFragment.
Now, when I start up the application, and the service retrieves the information, all is good! The ListFragment has its data populated and everything works great.
When I switch to the second Tab, I can just see a Loading Wheel, which is fine.
The issue comes when I switch back to the first Tab. When the service is started, and starts pulling down the data, I can see that its pulling it down in my logs, but nothing appears in my ListFragment. Its just blank, and its like the CursorLoader is not attached anymore.
The next weird thing, is when I close the application and relaunch it, the data is suddenly there in the list! But the bug again occurs when switching.
Any ideas on this? Its really bugging me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当片段被删除时,您必须调用
getLoaderManager.destroyLoader()
。You have to call
getLoaderManager.destroyLoader()
when the fragment is removed.