`
presses
  • 浏览: 115711 次
  • 性别: Icon_minigender_1
  • 来自: 中山
社区版块
存档分类
最新评论

creating menus

阅读更多

一、菜单提供了熟悉的接口展示app的功能及设置。android提供了标准的app菜单应付各种情况。

 

二、android提供了三种类型的菜单:Option Menu、Context Menu、Submenu。

 

三、Option Menu是activity的一组基本的menu items。由机器上的menu键触发。Option Menu包含两种Menu item:Icon Menu item、Expended Menu item。Icon Menu是由用户点击触发的处于界面底端的菜单。它最大可以有六个菜单,而且是唯一支持icon功能的menu item,也是唯一不支持checkbox和radio按钮的menu item。expanded menu是一个竖直列表。当用户点击Icon menu的"more"选项时弹出。它只会在Option menu超过六个时显视,Option Menu应该显视程序的基本功能或导航。当用户第一次按menu键时,系统会调用onCreateOptionsMenu()方法,你可能通过编程,用add()方法增加菜单或在xml中定义。当一个item被选中时,onOptionsitemSelected()会被回调,此时可以用getItemId()区分被选中的item。

 

四、Option Menu相关回调函数:onCreateOptionsMenu:第一次调用时触发,用于初始化相关item。onOptionItemSelected:在菜单被选中时触发。

 

onPrepareOptionsMenu:每次调用时触发。

 

五、Context Menu:Context Menu是一个浮动的菜单列表。功能与pc上的右击菜单类似。当你长时间(约两秒)按住一个view时会弹出来。Context Menu的创建及回调方法与Option Menu类似。区别在于创建完菜单后,在Activity中需要调用registerForContextMenu方法为view注册菜单。

 

六、SubMenu:Submenu是一个浮动的菜单列表。它是与Option Menu或Context Menu相关联的。Submenu不支持嵌套。创建subMenu的方法是在menu中调用

 

addSubMenu()取得submenu,然后在submenu中调用add,增加菜单。

 

七、define menus in xml。在res下建menu目录,然后建xxx.xml文件。在里面添加菜单。在onCreateXXXXXMenu中调用this.getMenuInflater().inflate()方法即可生成菜单。

 

八、menu group:添加item时,你可以把相关功能的item的groupID设置成一样,这样就可以一次设置一组菜单的visible、enable、checkable。

 

九、shortcut keys:shortcut key只能Option Menu有效。可以通过item的setAlphabeticShortcurt()/setNumericShortcut()/setShortcut()方法设置快捷键。

 

十、set an intent for a single menu item:当客户点击item时,你想固定地触发一个intent,你可以调用item.setIntent方法。

 

1
0
分享到:
评论

相关推荐

    matlab图形界面设计(英文原版)

    Creating a GUI M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 Laying Out a Simple GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 Creating the Figure . . . . . . ...

    Beginning.Drupal.8.B00UH97G24

    Chapter 7: Creating Menus Chapter 8: Drupal Blocks Chapter 9: Views Chapter 10: Creating Pages Chapter 11: Drupal Modules Chapter 12: Anatomy of a Module Chapter 13: Multilingual Capabilities Chapter ...

    Prentice.Hall.C++.GUI.Programming.with.Qt.4.2nd.Edition.2008.chm

    Creating Menus and Toolbars Setting Up the Status Bar Implementing the File Menu Using Dialogs Storing Settings Multiple Documents Splash Screens Chapter 4. Implementing Application ...

    Packt.Building.your.First.Mobile.Game.using.XNA4.2013

    A fast-paced, hands-on guide to building a 3D game for the Windows Phone 7 platform using XNA 4.0 Overview Building a 3D game for the Windows Phone 7 platform. ...Creating menus. How to build a 3D game!

    VB.NET Developer's Guide(4574).pdf

    Creating and Working with Menus 323 Adding Menus to a Form 323 Exercise 7.2 Adding a Menu to a Form at Design Time 323 Creating Dialog Boxes 1.Create a form. 2.Set the BorderStyle property of the ...

    javascript for dummies by Emily Vander Veer

    Introduction .................................................Chapter 9: Creating Menus............................................................................................181 Chapter 10: Creating

    Python Cookbook英文版

    9.2 Creating Menus with Tkinter 9.3 Creating Dialog Boxes with Tkinter 9.4 Supporting Multiple Values per Row in a Tkinter Listbox 9.5 Embedding Inline GIFs Using Tkinter 9.6 Combining ...

    Cocos Builder 1.0

    It’s ideal for quickly and accurately creating menus and other parts of the interface, but can also be used to create levels, particle systems or any other kind of Cocos2D node graphs.

    Windows 8.1 js揭秘(高清pdf)Windows 8.1 Apps with HTML5 and JavaScript Unleashed

    6) Menus and Flyouts 7) Using the ItemContainer, Repeater, and FlipView Controls 8) Using the ListView Control 9) Creating Data Sources 10) Storing Data with Windows Azure 11) App Events and ...

    WordPress Theme Design: A complete guide to creating professional WordPress themes

    * Set up dynamic drop-down menus, AJAX/dynamic and interactive forms * Download and install useful plug-ins and widgetize your theme * Improve post and page content using jQuery and ThickBox * Add ...

    Learn Java the Easy Way: A Hands-On Introduction to Programming

    Chapter 5: Polishing Your App by Adding Menus and Preferences Chapter 6: Deciphering Secret Messages Chapter 7: Creating Advanced GUIs and Sharing Your App Chapter 8: Make Secret Messages a Phone App ...

    TCL TK 语言8.5编程指导

    Chapter 12: Creating and Managing Menus 169 Introduction 169 Creating a menu 170 Adding menu buttons 175 Displaying a pop-up menu 178 Data entry application 180 Chapter 13: Creating the Address Book ...

    Joomla! 3 Beginne's Guide

    Chapter 8: Helping Your Visitors Find What They Want: Managing Menus Chapter 9: Opening Up the Site: Enabling Users to Log In and Contribute Chapter 10: Getting the Most out of Your Site: Extending ...

    Practical.GameMaker.Studio.Language.Projects

    Improve your game with GML backgrounds, sound and music, splash screens and menus, and effects< Include GML random and AI movements in your game Use GML loops, arrays, ds_lists, paths, and scripts Who...

    Foundations.of.Joomla.1484207505

    The book takes you through the steps of installing Joomla, configuring your database, creating a blog and a website, followed by instructions on creating new posts and adding content to your site....

    Professional Android 4 Application Development 源代码

    Creating and Using Menus and Action Bar Action Items Refreshing the Earthquake Monitor Going Full Screen Introducing Dialogs Let's Make a Toast Introducing Notifications Adding Notifications and ...

    Learning.Google.Apps.Script.1785882511

    Create custom menus and dialogs Parse and send emails Generate Google calendar events Build Translator and RSS reader applications Develop interactive web pages Design interactive web-forms Form a ...

    基于OPENGL的GUI开发源代码

    It provides an object-oriented API for creating windows, menus and other user interface elements, and an inheritance-based event handling model. GLOW also includes a full-featured and extensible ...

    Learning Drupal 6 Module Development

    This book will give you a clear, concise and, of course, practical guidance to take you from the basics of creating your first module to developing the skills to make you a Drupal developer to be ...

    Amplify Shader Editor 1.5.5.zip

    MINIMALISTIC toolbars and menus have been optimized to maximize workspace area without large intrusive nodes or menus. Creating nodes or new Shaders is as intuitive as creating a new Unity Material in...

Global site tag (gtag.js) - Google Analytics