dl DrawerLayout findViewById R id drawer layout ; if flag { dl closeDrawer Gravity LEFT ; dl closeDrawer Gravity RIGHT ; flag false; } else if flag false { dl openDrawer Gravity RIGHT ; dl closeDrawers ; flag true; }