Code example for MenuItem

Methods: getItemId

0
        Toast.makeText(this, "Clicked: " + str, Toast.LENGTH_SHORT).show();
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                mMenuDrawer.toggleMenu();
                return true; 
        } 
 
        return super.onOptionsItemSelected(item);
    } 
 
    @Override 
    public void onBackPressed() { 
        final int drawerState = mMenuDrawer.getDrawerState();
        if (drawerState == MenuDrawer.STATE_OPEN || drawerState == MenuDrawer.STATE_OPENING) {
            mMenuDrawer.closeMenu();
            return; 
        }