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

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.

主站蜘蛛池模板: 禄丰县| 郧西县| 隆林| 洛宁县| 绍兴县| 乳源| 绥宁县| 繁峙县| 崇州市| 丹阳市| 陕西省| 衢州市| 卢氏县| 甘肃省| 永嘉县| 巴中市| 沙河市| 丹阳市| 滕州市| 广州市| 镇安县| 金溪县| 比如县| 林西县| 嘉兴市| 锡林浩特市| 台中市| 元江| 体育| 宝坻区| 深州市| 察哈| 泽普县| 车险| 宜宾县| 屏东市| 武安市| 岚皋县| 九台市| 和林格尔县| 房山区|