I have created an app having five screens using Sherlock Fragment.
I can jump from one Screen to any other Screen.
But I want to save the last visited fragment name to back-stack,so that from current Fragment i can jump back to the parent(from where i came) Fragment.
I have tried this code,
FragmentManager fragManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragTransacion = fragManager.beginTransaction();
FragmentManager.BackStackEntry backEntry=getFragmentManager().getBackStackEntryAt(getActivity().getFragmentManager().getBackStackEntryCount());
String str=backEntry.getName();
fragTransacion.addToBackStack(str);
But my program gets stops unfortunately and telling me NullPointerException there
How can i achieve this ?
Here is my log-cat, logcat
You can do it like this
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.content, fragment);
transaction.addToBackStack("");
transaction.commit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With