获取“已经启动时调用doStart".从LoaderManager.为什么? [英] Getting "Called doStart when already started" from LoaderManager. Why?

查看:92
本文介绍了获取“已经启动时调用doStart".从LoaderManager.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码具有一个Activity,该Activity具有一个FragmentPagerAdapter,该FragmentPagerAdapter可以根据需要创建"n"个片段.活动有一个加载器,每个片段都有自己的加载器.所有加载程序都有唯一的ID.(活动的加载程序实际上决定了适配器中的页面数)

My code has an Activity, that has a FragmentPagerAdapter that creates 'n' fragments as necessary. Activity has a loader, and each fragment has its own loader. All loaders have unique ID. (Activity's loader in fact determines the number of Pages in the adapter)

我一直到处都收到这个警告,无法理解引起它的原因.看上去也并不重要,也可以查看LoaderManger的代码是否发出此警告,但仍然-警告通常是错误的征兆.

I keep getting this warning here and there and can't put my finger on what's causing it. It doesn't seem to be critical, also looking at the LoaderManger's code throwing this warning, but still - warnings are usually signs for bugs..

最初使用FragmentStatePagerAdapter,然后移到FragmentPagerAdapter,以为这可能是问题所在,但显然不是.

Had originally used FragmentStatePagerAdapter and then moved to FragmentPagerAdapter, thinking that could somehow be the issue - but obviously it's not.

发布代码确实会使它复杂化,并且增加的很少.

Posting code would really complicate this and add very little.

有什么想法吗?

推荐答案

在您的片段中,将initLoader方法移到onActivityCreated方法内.

in your fragment move your initLoader method inside the onActivityCreated method.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);

    LoaderManager lm = getLoaderManager();
    lm.initLoader(LOADER_ID, null, this);
}

这篇关于获取“已经启动时调用doStart".从LoaderManager.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆