【问题标题】:Remove fragment crash移除片段崩溃
【发布时间】:2014-05-28 16:11:25
【问题描述】:

我添加和删除这样的片段:

添加

getSherlockActivity().getSupportFragmentManager()
                                .beginTransaction()
                                .setCustomAnimations(R.anim.slide_in_bottom, R.anim.slide_out_top, R.anim.slide_in_top, R.anim.slide_out_bottom)
                                .add(R.id.fragment_explore, fragment)
                                .addToBackStack(null)
                                .commit();
ActivityMain.BACKSTACK_EXPLORE.add(fragment);

移除

Fragment depopFragment = BACKSTACK_EXPLORE.get(BACKSTACK_EXPLORE.size() - 1);
                    getSupportFragmentManager().beginTransaction()
                                                .setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_bottom, R.anim.slide_in_bottom, R.anim.slide_out_top)
                                                .remove(depopFragment)
                                                .commit();
                    BACKSTACK_EXPLORE.remove(depopFragment);

有一个快速的幻灯片动画。片段从底部来,又回到底部。

我的问题是当你按下后退按钮(depop 片段)并且在动画完成之前你触摸出现在后面的活动。

它给了我一个简单的致命信号 11 错误(在三星 Galaxy s3 上更常见)

有什么想法吗?

【问题讨论】:

  • 可能与您的问题无关,但将片段(存储上下文)保存在静态容器中是不好的做法。这可能会导致上下文泄漏。
  • Reptification :这只发生在三星 Galaxy s3 (android 4.3) 上,从不在 nexus4(android4.4) 上。这仅在删除片段时发生。只有当“fragment2 above”的删除动画仍在进行时,我才点击“fragment1 behind”

标签: java android android-fragments error-handling actionbarsherlock


【解决方案1】:

我解决了,和onCreateAnimation()有关,我以前知道动画什么时候结束

view.setLayerType(LAYER_TYPE_NONE, null); 

这条线造成了崩溃。它似乎与硬件加速有关,很可能只在 android 4.3 上

查看此链接:Disable hardware acceleration, backward compatibility

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-20
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多