美文网首页
java.lang.IllegalStateException:

java.lang.IllegalStateException:

作者: MarkShaun | 来源:发表于2017-03-08 18:08 被阅读15次

    场景:ActivityA嵌套Fragment,点击按钮跳转到ActivityB, 在B 页面进行一些操作返回A页面时在onActivityResult() 中刷新fragment。

    private void initFragment() {
            String ids = StringUtil.LongIds2str(mIds);
            if (fragment != null ) {
                fragment = new TopicListFragment().newInstance(ids);
                getSupportFragmentManager().beginTransaction().replace(R.id.fl_container, fragment).commitAllowingStateLoss();
            } else {
                fragment = new TopicListFragment().newInstance(ids);
                getSupportFragmentManager().beginTransaction().add(R.id.fl_container, fragment).commit();
            }
    }
    

    http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html

    相关文章

      网友评论

          本文标题:java.lang.IllegalStateException:

          本文链接:https://www.haomeiwen.com/subject/nhxigttx.html