官术网_书友最值得收藏!

Introduction

The Android OS is an ever-changing environment. The earliest Android devices (prior to Android 3.0), were required to have a hardware menu button. Though a hardware button is no longer required, menus are no less important. In fact, the Menu API has expanded to now support three different types of menus:

  • Options Menu and Action Bar: This is the standard menu, which is used for global options of your application. Use this for additional features such as search, settings, and so on.
  • Contextual Mode (Contextual Action Mode): This is generally activated by long press. (Think of this as similar to a right-click on the desktop.) This is used to take an action on the pressed item, such as replying to an e-mail or deleting a file.
  • Pop-up Menu: This provides a pop-up selection (like a spinner) for an additional action. The menu options are not meant to affect the item pressed, instead use Contextual Mode as described previously. An example would be hitting the share button and getting an additional list of share options.

Menu resources are similar to other Android UI components; they are generally created in XML, but can be created in code as well. Our first recipe, as shown in the following section, will show the XML menu format and how to inflate it.

主站蜘蛛池模板: 蓬莱市| 田阳县| 措勤县| 兰州市| 广昌县| 陈巴尔虎旗| 黎平县| 曲阳县| 宜兰县| 招远市| 武夷山市| 高陵县| 苍南县| 曲阜市| 青州市| 青田县| 景东| 区。| 花莲县| 云南省| 区。| 灵川县| 岳阳市| 工布江达县| 渝中区| 徐水县| 腾冲县| 仲巴县| 门源| 宁阳县| 福鼎市| 且末县| 安宁市| 施秉县| 原平市| 汽车| 邵东县| 噶尔县| 山丹县| 大荔县| 平谷区|