活动结果片段索引超出范围:0x20001 [英] Activity Result Fragment Index Out Of range : 0x20001

查看:344
本文介绍了活动结果片段索引超出范围:0x20001的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,onActivityResult()不被传递到片段,我觉得有问题,主要活动传递onActivityResult()的片段,我得到这样的警告,活动结果片段索引超出范围和正因如此,我不能重装我嵌套的片段。

I have problem with onActivityResult() not being passed to fragment, I think there is problem with main activity for passing onActivityResult() to the fragment, and I got this warning, "Activity result fragment index out of range" and for this reason, I can not reload my nested fragments.

我的Aplication采用抽屉式导航,而我认为寻呼机中的片段为一体的菜单,所以认为寻呼机重载嵌套的片段,我想重装视图寻呼机所以里面查看传呼机片段获得最新的更新。我叫startActivityForResult从片段内viewpager

My Aplication uses navigation drawer, and I have view pager in a fragment as one the menu, and so the view pager reloads nested fragments, and I want to reload the view pager so fragments inside view pager get the latest updates. I call startActivityForResult from fragment inside viewpager

    Intent i = new Intent(getActivity(), AddEditRecurring.class);
                i.putExtra("isEditMode", true);
                i.putExtra("itemID", itemID);
                i.putExtra("name", name);
                i.putExtra("type", type);
                i.putExtra("catId", categoryID);
                i.putExtra("repeat", startOn);
                i.putExtra("price", String.valueOf(amount));

                startActivityForResult(i, 1);

和调用AddEditRecurring活动,并经过用户已经开展这项活动进行,活动结束,并发送活动的结果重新载入viewpager。但在这种情况下,活动未能通过onActivityResult到片段,我不能重装视图寻呼机。

And call AddEditRecurring activity, and after user has done with this activity, the activity closed and send activity result to reload the viewpager. But in this case, activity fails to pass onActivityResult to fragment and I can not reload the view pager.

编辑:

我浏览Android的支持库,得到了这一点,

I browsed android support library and got this,

 /**
 * Dispatch incoming result to the correct fragment.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    mFragments.noteStateNotSaved();
    int index = requestCode>>16;
    if (index != 0) {
        index--;
        if (mFragments.mActive == null || index < 0 || index >= mFragments.mActive.size()) {
            Log.w(TAG, "Activity result fragment index out of range: 0x"
                    + Integer.toHexString(requestCode));
            return;
        }
        Fragment frag = mFragments.mActive.get(index);
        if (frag == null) {
            Log.w(TAG, "Activity result no fragment exists for index: 0x"
                    + Integer.toHexString(requestCode));
        } else {
            frag.onActivityResult(requestCode&0xffff, resultCode, data);
        }
        return;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

任何人都知道这是什么意思?

Anyone knows what does it mean?

推荐答案

呼叫从你的孩子的活动方式,如果你错过了调用这个 getParentFragment()。startActivityForResult

Call method from your child activity if you have missed to call this getParentFragment().startActivityForResult

这篇关于活动结果片段索引超出范围:0x20001的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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