Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Actionbar Left Menu

I am working on android application. I have to add a menu on the left side of Action Bar. I am able to add menu on the right side but along with right side menu, I also want to add a menu on left side of Action Bar just like :

I have spent hours on searching how to achieve that left side menu, but no success. How can I achieve that? Thanks!

like image 354
Muhammad Salman Farooq Avatar asked Feb 26 '14 14:02

Muhammad Salman Farooq


2 Answers

This is called Navigation Drawer, You can look at the official android tutorial here, and this one too

like image 173
Mahmoud Hashim Avatar answered Sep 19 '22 10:09

Mahmoud Hashim


If you are not specifically into the navigational drawer, like a back button or anything you like, you can use

ActionBar actionbar = getSupportActionBar();
actionbar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);

and call

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() ==android.R.id.home){
            //todo work here
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
like image 41
Super User User Avatar answered Sep 19 '22 10:09

Super User User