문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top