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

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.

主站蜘蛛池模板: 屏山县| 内江市| 重庆市| 龙口市| 临湘市| 岚皋县| 宽城| 伽师县| 香港 | 吉木萨尔县| 蓝田县| 江西省| 阳曲县| 夏河县| 鹰潭市| 塔河县| 佛坪县| 枣庄市| 青冈县| 合阳县| 烟台市| 平利县| 古田县| 平武县| 视频| 清新县| 从江县| 定兴县| 方城县| 宜丰县| 曲靖市| 元氏县| 循化| 隆子县| 哈巴河县| 永泰县| 阳谷县| 华宁县| 通河县| 莱芜市| 马公市|