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

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.

主站蜘蛛池模板: 射阳县| 包头市| 清新县| 麻江县| 图片| 锦州市| 伊宁市| 介休市| 乌兰察布市| 潼南县| 西峡县| 乌兰察布市| 绵竹市| 新昌县| 衡水市| 南郑县| 宜兰县| 连平县| 朔州市| 精河县| 莱州市| 浑源县| 阿克苏市| 增城市| 榆树市| 乡城县| 大港区| 托克逊县| 响水县| 北碚区| 沽源县| 安图县| 忻城县| 个旧市| 威海市| 沂源县| 吴川市| 靖远县| 江都市| 怀柔区| 无为县|