6

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!

Mahmoud Hashim
  • 550
  • 5
  • 13
Muhammad Salman Farooq
  • 1,325
  • 9
  • 26
  • 54
  • 1
    A navigation drawer might be what you are looking for: https://developer.android.com/design/patterns/navigation-drawer.html – FD_ Feb 26 '14 at 14:42

3 Answers3

9

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

Mahmoud Hashim
  • 550
  • 5
  • 13
  • I have added that Navigation Drawer. I am getting the following error when I click on icon to pull the drawer "span_exclusive_exclusive spans cannot have a zero length" What is this error? – Muhammad Salman Farooq Feb 26 '14 at 16:59
  • @MuhammadSalmanFarooq have you followed the tutorials exactly, you can download the exercise files found on these pages and explore the code, it the error persists you can post your problem in another question with some code to let others help you. – Mahmoud Hashim Feb 26 '14 at 17:24
1

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

You cant align menu to left .you should use customview for your actionbar

zohreh
  • 1,055
  • 1
  • 9
  • 26