Fragment management?

I am using android Library_JakeWharton_ActionBarSherlock to implement Facebook related and other applications like a sliding bar,

Faced with a problem going backwards, i.e. from fragment B β†’ from fragment A.

I have a fragment called "Result", and another - "Details", when the user clicks on a specific element in the "Detailed fragment of the result".

private void switchFragment(Fragment fragment) {
    if (getActivity() == null)
        return;

    if (getActivity() instanceof FragmentInitializer) {
        FragmentInitializer fca = (FragmentInitializer) getActivity();
        fca.switchContent(fragment);
    }
}

used this method to move from one fragment to another fragment.

How can I return from the Parts Fragment to the Result Fragment. Below is my class of result fragments

public class Result_Fragments extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        LinearLayout lnr_main = (LinearLayout) inflater.inflate(R.layout.result_layout, null);
        getInit(lnr_main);
        return lnr_main;
    }
}

I tried below code.

1) getFragmentManager (). PopBackStack (); 2) android.support.v4.app.FragmentManager mFragmentManager = getFragmentManager ();

            if(mFragmentManager.getBackStackEntryCount() > 0){
                mFragmentManager.popBackStack();
            }
+4
1

.

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.left_framelayout, DetailFragment);
transaction.addToBackStack(null);
transaction.commit();
0

All Articles