Navigation Drawer Activity [closed]

1

I have the menu that comes by default in android studio, I would like to make it work. I think it would be calling a fragment but I do not know where to start.

MainActivity

implements  NavigationView.OnNavigationItemSelectedListener,BlankFragment.OnFragmentInte actionListener {

 @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();
        Fragment fragment;

        if (id == R.id.nav_gallery) {

            fragment = new BlankFragment();
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.container, fragment);
            ft.commit();

        } 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;

    }

When I open the menu and choose the gallery the application is closed

    
asked by jorje garcia 28.08.2016 в 02:10
source

0 answers