White screen after going back through Fragments

戏子无情 提交于 2019-12-01 09:19:20
Ajay Pandya

You can manage back stack and screen for exit like

@Override
public void onBackPressed() {
    if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
        getSupportFragmentManager().popBackStack();
    } else {
        super.onBackPressed();
    }
}

This is because you are adding all your fragments programmatically. On pressing back buttons, you eventually remove the first fragment that you added as well.

The reason you get it back on launching the application is because you add the fragment again.

I would suggest overwrite your back button. Whenever you pop fragment, check to see that it's not your first fragment and then pop it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!