Use details and optimization of MenuItem on android-Actionbar
MenuItem is an element on actionbar. This control is often used in uidesign.
Usage:
1. Compile the menu. xml resource file
You can set the icon file, but the display effect may not be very good.
ShowAsAction indicates whether it appears in actinbar. Commonly Used always, ifroom, and never;
2. Load in action:
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); return true; }
Note: You can customize the properties of a button, just like a custom control,
First, write the layout file:
Then, you only need to add several lines of code to the oncreateMenu () method of action, locate the actionitem, and call the setActionView () method.
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); inBoxMenuItem = menu.findItem(R.id.action_inbox); inBoxMenuItem.setActionView(R.layout.menu_item_view); return true; }