onback pressed data not showing in fragments

人走茶凉 提交于 2019-11-28 01:45:22

Please call addToBackStack(null) when you perform fragment transaction.

fragmentManager.beginTransaction()
            .replace(R.id.mainContent, fragment)
            .addToBackStack(null)
            .commit();

Please update your OnCreateView() as below:

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        if (view != null) {
        if (view.getParent() != null) {
            ((ViewGroup)view.getParent()).removeView(view);
        }
        return view;
    }

    View v=inflater.inflate(R.layout.tests, container, false);

I hope this helps

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