Android Actionbar Left Menu
10,126
Solution 1
This is called Navigation Drawer
, You can look at the official android tutorial here, and this one too
Solution 2
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);
}
Author by
Muhammad Salman Farooq
J2EE developer at Digital Processing Systems Inc., Pakistan. www.d-p-s.com
Updated on June 25, 2022Comments
-
Muhammad Salman Farooq almost 2 years
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!
-
Muhammad Salman Farooq about 10 yearsI 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?
-
Mahmoud Hashim about 10 years@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.