Example analysis of menu usage in Android Development

This article describes the menu usage of Android development. Share with you for your reference, as follows:

Android phones use a key "menu" to display menus.

To realize the menu function, first create the menu through the method oncreateoptionmenu. There are two ways to create the menu: one is to directly import the XML file with menu, and the other is to add it directly with the method of menu class. After creating the menu, use the event listener onoptionitemselected to listen for events that can be triggered.

The following example has two activities. The above two methods are used to implement the menu. In each menu, there is an event listener to jump and exit the activity.

1. The menu file RES / menu / menu.xml under the resource file

Activity01.Java

Activity02.java

This example uses two activities. Don't forget to declare them in androidmanifest.xml.

PS: for the properties and functions related to the androidmanifest.xml file, please refer to the online tools of this website:

Description of Android manifest functions and permissions: http://tools.jb51.net/table/AndroidManifest

More readers interested in Android related content can view the special topics of this site: introduction and advanced tutorial of Android development, summary of Android debugging skills and common problem solving methods, summary of Android basic component usage, summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>