Answer the question
In order to leave comments, you need to log in
How to use the fragment stack?
I have 3 fragments called one after another, each one is added to the stack, when I close 3 fragments, I call popBackStack and 2 fragments open for me and more components from 3 fragments are visible on it. Why?
Here is the menu
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
FragmentTransaction ftrans = getFragmentManager().beginTransaction();
int id = item.getItemId();
if (id == R.id.nav_teory) {
ftrans.replace(R.id.content_main, fteory, "ftheory");
setTitle("Теория");
ftrans.addToBackStack("ftheory");
} else if (id == R.id.nav_test) {
ftrans.replace(R.id.content_main, ftest);
setTitle("Тест");
ftrans.addToBackStack("ftest");
} else if (id == R.id.nav_exit) {
Intent intent = new Intent();
setResult(RESULT_OK);
finish();
} ftrans.commit();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
fuser = new FragmentUser();
FragmentTransaction ftrans = getFragmentManager().beginTransaction();
ftrans.replace(R.id.content_main, fuser);
Bundle bundle = new Bundle();
bundle.putInt("Points", Points);
fuser.setArguments(bundle);
ftrans.addToBackStack("fuser");
ftrans.commit();
getActivity().getFragmentManager().popBackStack();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question