0

嗨,我正在开发我正在使用操作栏 Sherlock 的 android 应用程序。我的应用程序在 3 个带有 3 个选项卡的片段中包含一个主要活动。如果我单击列表项,我的第一个选项卡会显示列表视图,它会打开新的详细信息活动。因此,当我关闭详细信息活动时,我想要自动打开另一个选项卡。

所以我的代码看起来像

public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        Intent intent = new Intent(getActivity(), CardDetails1.class);
        startActivityForResult(intent, 7);
    }

我正在做的活动结果是:

@Override @SuppressLint("NewApi")
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode == 7)
        {   
            getActivity().getActionBar().setSelectedNavigationItem(2);
        }
    }

但是当我点击返回时,它给了我以下错误

08-08 10:36:58.149: E/AndroidRuntime(7351): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=131079, result=0, data=null} to activity {com.example.sample/com.ecample.sample.LeftAndRightActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3398)
08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3448)
08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.app.ActivityThread.access$1100(ActivityThread.java:139)
08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-08 10:36:58.149: E/AndroidRuntime(7351):     at android.os.Looper.loop(Looper.java:156)

任何对此有解决方案的人。我需要帮助。谢谢你。

4

1 回答 1

0

利用:transaction.commitAllowingStateLoss();

添加或执行FragmentTransaction导致Exception.

于 2013-11-14T07:01:18.887 回答