Question

I am using action bar and I can add buttons towards the top right like this:

@Override
public boolean onCreateOptionsMenu(Menu menu) 
   menu.add("Save").setIcon(R.drawable.action_save).
         setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
   return true;
}

But I would like to add a Cancel button towards the top left. Is there a way to do add a button towards the left?

Was it helpful?

Solution

What are you trying to do this for? If it's contextual, you should maybe use a contextual action menu. This would allow you to have a done or cancel button on the left.

See this guidance about contextual menus:

http://developer.android.com/guide/topics/ui/menus.html#context-menu

Sorry I would have posted this as a comment but haven't got enough rep.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top