1

I've searched all over Google trying to find the answer but haven't been able to find an answer. I'm using the "Create Navigation Drawer Activity" template in Android Studio. How do I add my fragments to the Navigation Drawer?

Here's where I assume I add the fragments:

    public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
        // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_slideshow) {

    } else if (id == R.id.nav_manage) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

Based on tutorials I've seen, I've tried adding the following in the if statements with no success:

    fragment = new ItemFragment();
Steve C.
  • 1,333
  • 3
  • 19
  • 50
  • Possible duplicate of [Switch between Fragments with onNavigationItemSelected in new Navigation Drawer Activity template (Android Studio 1.4 onward)](http://stackoverflow.com/questions/32944798/switch-between-fragments-with-onnavigationitemselected-in-new-navigation-drawer) – ACBM Apr 16 '16 at 23:53
  • @user3424545 this isn't a duplicate. I didn't see that one. I gave up on this question though. Didn't solve my problem. If I run into this issue again, I'll be sure to check that link. Thanks – Steve C. Apr 17 '16 at 00:37

0 Answers0