In android studio created an application using the template of the drawer. Made two fragments and generated markup for them. In MainActivity: Create two fragments
FragmentPipes fragmentPipes; FragmentTanks fragmentTanks; In onCreate () they initialize
fragmentPipes = new FragmentPipes(); fragmentTanks = new FragmentTanks(); So that when you click on the menu item to change the fragment in the container content_main.xml created FrameLayout with id container. in onNavigationItemSelected (MenuItem item) I set the action by clicking on the menu item
int id = item.getItemId(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); if (id == R.id.nav_pipes) { fragmentTransaction.replace(R.id.container, fragmentPipes); } else if (id == R.id.nav_tanks) { fragmentTransaction.replace(R.id.container, fragmentTanks); } After launching the application, when you select the corresponding item in the drawer with one of these fragments, the fragment is not replaced. I do not get any errors, just nothing happens.
All code is laid out by Calculator