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

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.

主站蜘蛛池模板: 衡阳县| 从化市| 九江市| 翁牛特旗| 云和县| 惠来县| 安徽省| 革吉县| 刚察县| 平远县| 盖州市| 湘乡市| 佛教| 锦屏县| 万安县| 陵川县| 大英县| 同江市| 华阴市| 岗巴县| 正阳县| 乐清市| 大余县| 石渠县| 和平区| 泗阳县| 遂平县| 泗水县| 甘谷县| 丰原市| 建昌县| 长丰县| 阜新市| 游戏| 湟源县| 汕头市| 宿州市| 伊金霍洛旗| 仙居县| 大田县| 孙吴县|