There is a created NavigationDrawer , connected to it tabs. It turns out that the first Item with tabs (fragments) in the Drover works correctly, and already the 2nd one displays the same information ( TextView ), the one that is in the first Item and in its tabs.
Tell me how to fix it, in the code, if possible?
Here, in fact, the code itself of the 2nd item and its tabs in activation:
MainActivity :
public class MainActivity extends AppCompatActivity { private static final int LAYOUT = R.layout.activity_main; private Drawer.Result drawerMenu; private ViewPager viewPager; private Toolbar toolbar; private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.myTheme2); super.onCreate(savedInstanceState); setContentView(LAYOUT); initTabs(); // ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅ΠΌ Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar); if (toolbar !=null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } initializeNavigationDrawer(toolbar); } private void initTabs() { viewPager = (ViewPager) findViewById(R.id.viewPager); // ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅ΠΌ TabLayout tabLayout = (TabLayout)findViewById(R.id.tabLayout); TabFragmentFish adapter = new TabFragmentFish(getSupportFragmentManager()); viewPager.setAdapter(adapter); tabLayout.setupWithViewPager(viewPager); } @Override public void onBackPressed() { if (drawerMenu != null && drawerMenu.isDrawerOpen()) { drawerMenu.closeDrawer(); } else { super.onBackPressed(); } } //ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ ΠΡΠ°Π²Π΅ΡΠ° private void initializeNavigationDrawer(Toolbar toolbar) { drawerMenu = new Drawer() .withActivity(this) .withToolbar(toolbar) .withActionBarDrawerToggle(true) .withHeader(R.layout.drawer_header) //ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΡΠ΅ΠΌΠΎΠ² Π² ΡΡΠΎΡΠΊΡ .addDrawerItems( new PrimaryDrawerItem() .withName(R.id.aqua_fish) .withIdentifier(1) .withIcon(FontAwesome.Icon.faw_circle), new PrimaryDrawerItem() .withName(R.id.aqua_plant) .withIdentifier(2) .withIcon(FontAwesome.Icon.faw_leaf), new PrimaryDrawerItem() .withName(R.id.aqua_water) .withIdentifier(3) .withIcon(FontAwesome.Icon.faw_tint), new PrimaryDrawerItem() .withName(R.id.aqua_lighting) .withIdentifier(4) .withIcon(FontAwesome.Icon.faw_lightbulb_o), new PrimaryDrawerItem() .withName(R.id.aqua_co2) .withIdentifier(5) .withIcon(FontAwesome.Icon.faw_circle), new PrimaryDrawerItem() .withName(R.id.aqua_filtration) .withIdentifier(6) .withIcon(FontAwesome.Icon.faw_filter), //--------------------------------------------- Secondary new DividerDrawerItem(), new SecondaryDrawerItem() .withName(R.id.about) .withIdentifier(7), new SecondaryDrawerItem() .withIdentifier(8) .withName(R.id.exit)) //Π Π΅Π°Π»ΠΈΠ·ΡΠ΅ΠΌ ΠΊΠ»ΠΈΠΊ ΠΏΠΎ Π°ΠΉΡΡΠΌΠ°ΠΌ .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id, IDrawerItem drawerItem) { switch (drawerItem.getIdentifier()){ case 1: TabFragmentFish adapter = new TabFragmentFish(getSupportFragmentManager()); viewPager.setAdapter(adapter); tabLayout.setupWithViewPager(viewPager); break; case 2: TabFragmentAdapterPlants adapterPlants = new TabFragmentAdapterPlants(getSupportFragmentManager()); viewPager.setAdapter(adapterPlants); tabLayout.setupWithViewPager(viewPager); break; //ΠΠΈΠ½ΠΈ ΠΎΠΊΠΎΡΠΊΠΎ "ΠΠ± Π°Π²ΡΠΎΡΠ΅ Ρ Π·Π°ΠΊΡΡΡΠΈΠ΅ΠΌ ΠΠ" case 7: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this, R.style.AppCompatAlertDialogStyle); builder .setTitle("ΠΠ± Π°Π²ΡΠΎΡΠ΅") .setMessage("ΠΠ²ΡΠΎΡ:ΠΡΡΠ΅ΠΌ ΠΠΈΡΡΡΠΎΠ²ΡΠΊΠΈΠΉ"+"\n\nEmail: artm.mishurovskiy@gmail.com") .setCancelable(false) .setNegativeButton("ΠΠΊ", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); break; //ΠΡΡ
ΠΎΠ΄ ΠΈΠ· ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ case 8: finish(); break; } } }) .build(); } } The adapter itself and tabs are created in it:
public class TabFragmentAdapterPlants extends FragmentPagerAdapter { //Create massive private String[] tabs; private FragmentTransaction fTrans; public TabFragmentAdapterPlants(FragmentManager fm) { super(fm); //Create tabs tabs= new String[] { "Π Π°ΡΡΠ΅Π½ΠΈΡ", "ΠΠΎΠ»Π΅Π·Π½ΠΈ ΡΠ°ΡΡΠ΅Π½ΠΈΠΉ", "ΠΠΎΠ΄ΠΎΡΠΎΡΠ»ΠΈ" }; } //ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ Π’Π°Π±ΠΎΠ² ΡΡΠΎ Π± ΠΏΠ΅ΡΠ΅Π΄Π°ΡΡ ΠΈΡ
Π² ΡΠ²ΠΈΡΡ @Override public CharSequence getPageTitle(int position) { return tabs[position]; } //ΠΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΌΠ΅ΠΆΠ΄Ρ ΡΡΠ°Π³ΠΌΠ΅Π½Π°ΠΌΠΈ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ 0,1,2 @Override public Fragment getItem(int position) { switch (position){ case 0: return FragmentPlants.getInstance(); case 1: return FragmentsPlantsDisease.getInstance(); case 2: return FragmentPlantsAlgae.getInstance(); } return null; } //ΡΠ°Π±Ρ Π² ΡΠΈΡΠΈΠ½Ρ !! @Override public int getCount() { return tabs.length; } } Fragment to which the adapter switches:
public class FragmentPlants extends Fragment { private static final int LAYOUT = R.layout.fragments_plants2; private View view; public static FragmentPlants getInstance(){ Bundle args = new Bundle(); FragmentPlants fragmentPlants = new FragmentPlants(); fragmentPlants.setArguments(args); return fragmentPlants; } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(LAYOUT, container, false); return view; } } 

ViewPager, and not oneViewPagerin theViewPager. Then, from the Drover, call these fragments, which contain their own pager. In the active container only to display the fragment and all. See this example - pavlofff