So I want my menu to display a sub menu below it when the menu is clicked. I've tried several ways of doing that but I just cant make it work. The app crashes whenever I clicked the menu.
Here's my Java
  @SuppressWarnings("StatementWithEmptyBody")  @Override  public boolean onNavigationItemSelected(MenuItem item) {      // Handle navigation view item clicks here.      int id = item.getItemId();            if (id == R.id.nav_gallery) {          MenuItem acc1 = (MenuItem) findViewById(R.id.manage_profile);        }        else if (id == R.id.manage_profile) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        else if (id == R.id.nav_gallery2) {          }        else if (id == R.id.search_school) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        else if (id == R.id.school_vielnearby) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        else if (id == R.id.school_vielall) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        else if (id == R.id.nav_gallery3) {        }        else if (id == R.id.search_organization) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        else if (id == R.id.organization_vielnearby) {            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);      }        else if (id == R.id.organization_vielall) {          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);          drawer.closeDrawer(GravityCompat.START);        }        return true;  }      And here's my menu xml
      <?xml version="1.0" encoding="utf-8"?>  <menu xmlns:android="http://schemas.android.com/apk/res/android">  <group      android:id="@+id/menuall">        <item            android:id="@+id/nav_gallery"          android:icon="@android:drawable/ic_menu_gallery"          android:title="My Account">      </item>        <item          android:id="@+id/manage_profile"          android:checked="false"          android:visible="false"          android:title="      Manage Account">      </item>        <item          android:id="@+id/nav_gallery2"          android:icon="@android:drawable/ic_menu_gallery"          android:title="School">      </item>        <item          android:id="@+id/search_school"          android:checked="false"          android:visible="false"          android:title="      Search School"/>        <item          android:id="@+id/school_vielnearby"          android:checked="false"          android:visible="false"          android:title="      View Nearby"/>        <item          android:id="@+id/school_vielall"          android:checked="false"          android:visible="false"          android:title="      View All"/>        <item          android:id="@+id/nav_gallery3"            android:icon="@android:drawable/ic_menu_gallery"          android:title="Organization">      </item>        <item          android:id="@+id/search_organization"          android:checked="false"          android:visible="false"          android:title="      Search Organization"/>        <item          android:id="@+id/organization_vielnearby"          android:checked="false"          android:visible="false"          android:title="      View Nearby"/>        <item          android:id="@+id/organization_vielall"          android:checked="false"          android:visible="false"          android:title="      View All"/>    </group>    </menu>      So basically I want my app to set the visibility to true when the menu is clicked
No comments:
Post a Comment