How to create custom option menu in android

拈花ヽ惹草 提交于 2019-12-04 12:41:32

You can Create in two ways

1.Statically.

2.Dynamically.

Am explaining the easiest method of adding menus.

Step 1: Create a new Android Application.

Step 2: After onCreate() method write onCreateOptionMenu();

Step 3: In onCreateOptionMenu() Write these lines

menu.add(11, 21, 1, "Gowtham").setIcon(R.drawable.ic_launcher);

Here "Gowtham" is title of your menu item You can Home&Email use instead of "Gowtham".

Ans use Any images Instead of ic.launcher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!