From this post I am going to start series posts about Menu. Menu is very important. I will try to show all actions with menus in next posts.
Maybe it will be better to write one big article,but there are 2 problems from my side.
- Now I have no free time. All team works hard because we want to publish our updated applications in earlier November
- I like short but useful examples in manner how to
There are 3 types of menus:
- Options menus
- Context menus
- Sub menus
In this post I will show how to create Options menu and add menu items.
For creating need to override method onCreateOptionsMenu in Activity.
This code snippet shows how to create Options menu and add one menu item.
@Overridepublic boolean onCreateOptionsMenu(Menu menu){...menu.add(groupId,itemId,order,title);...return super.onCreateOptionsMenu(menu)}Now I will add correct data.
Example:
menu.add(0, ITEM,0,"Menu item");
Second parameter is itemId. For it need to write:
private static final int ITEM = Menu.FIRST;
As you can see creating Options menu and adding menu items are simple operations.
No related posts.

Recent Comments