码迷,mamicode.com
首页 > 移动开发 > 详细

3.App Resources-Resource Types/Menu Resource

时间:2014-11-03 16:15:19      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:des   android   cWeb   style   blog   http   io   color   ar   

1. Menu Resource

  A menu resource defines an application menu (Options Menu, Context Menu, or submenu) that can be inflated with MenuInflater.

//res/menu/example_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1" android:title="item1" android:showAsAction="ifRoom|withText"/> <item android:id="@+id/submenu" android:title="submenu_title" android:showAsAction="ifRoom|withText" > <menu> <item android:id="@+id/submenu_item1" android:title="submenu_item1" /> <item android:id= "@+id/submenu_item2" android:title="submenu_item2" /> </menu> </item> <group android:id="@+id/group"> <item android:id="@+id/group_item1" android:title="group_item1" /> <item android:id="@+id/group_item2" android:title="group_item2" /> </group> </menu>
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.example_menu, menu);
    return true;
}

  bubuko.com,布布扣     bubuko.com,布布扣

  Pay attention to the property "showAsAction"

    When and how this item should appear as an action item in the Action Bar.

    bubuko.com,布布扣

 

3.App Resources-Resource Types/Menu Resource

标签:des   android   cWeb   style   blog   http   io   color   ar   

原文地址:http://www.cnblogs.com/iMirror/p/4071232.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!