Skip to content Skip to sidebar Skip to footer

Onback Pressed Data Not Showing In Fragments

I am using navigation drawer in my app,I have fragments like F1,F2 and so on..and in every fragment I am parsing data and display in listview,everything is works fine if I go throu

Solution 1:

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

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

Solution 2:

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


Post a Comment for "Onback Pressed Data Not Showing In Fragments"