5. User Interface/menu

Source: Internet
Author: User

1. Menu

Three fundamental types of menus or action presentation on all versions of Android:

<1> option menu and action bar

Android 2.3 or lower, reveal the Options menu panel by pressing menu button

Android 3.0 or higher, Options menu are presented by the action bar as a combination of on-screen action items and overflow options

<2> context menu and contextual Action Mode

Floating menu that appears when user performs a long_click on an element

<3> popup menu

Displays a list of items in a vertical list that's anchored to the view that invoked the menu.

 

2. Defining a menu in XML

Define a menu and all its items in an XML menu resource. then inflate the menu resource (load it as a menu object) in activity or fragment

<Menu> a container for menu items.

<Item> A single item in a menu

This element may contain in a nested <menu> element in order to create a submenu.

<Group> invisible container for <item> Elements

<?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android">    // File menu    <item android:id="@+id/file"          android:title="@string/file" >        <!-- "file" submenu -->        <menu>            <item android:id="@+id/create_new"                  android:title="@string/create_new" />            <item android:id="@+id/open"                  android:title="@string/open" />        </menu>    </item>       // Edit Menu    <item android:id="@+id/edit"           .......></menu>

 

3. Creating an Options Menu

Android 2.3 or lower. The contents of your options menu appear at the bottom of the screen when the user pressesMenuButton,

    

Android 3.0 and higher, items from the Options menu are available in the action bar.

By default, the system places all items in the Action overflow, which the user can reveal with the action overflow icon on the right side

Of the action bar

To enable quick access to important actions, you can promote a few items to appear in the action bar by adding

Android: showasaction = "ifroom" to the corresponding <item> Elements

5. User Interface/menu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.