Android Studio - Drawer App Example with Working Fragments

Zujonuriz 2017-10-14

Views 10

A quick and simple tutorial for creating a drawer app in Android Studio. This is using the drawer template in Android Studio, which isnt much of a template as it doesnt show you how to switch containers (change pages).\r
\r
Well, this annoyed me as I struggle to make my way through Java on a good day. Finally I figured it out. Its incredibly simple, just the people on StackOverflow make everything more complex than it needs to be.\r
\r
Source, compiled with Android Studio 2.3, available at: \r
\r
( dont just copy paste, learn what the code does first! )\r
\r
2 pieces of code are used in this video. Ive included them below for copy/pasting.\r
\r
//onFragmentInterion public void onFragmentInterion(Uri uri){ //you can leave it empty }\r
\r
//onNavigationDrawerItemSelected Fragment fragment = null; switch (position) { case 0: fragment = new FragmentOne(); break; case 1: fragment = new FragmentTwo(); break; case 2: fragment = new FragmentThree(); break; } if (fragment != null) { FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransion() .replace(R.id.container, fragment) .commit(); }

Share This Video


Download

  
Report form