Cosc 5/4730 Blackberry and Android: Menus. BLACKBERRY.

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Quiz, Walkthrough, Exercise, Lifecycles, Intents.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
MODULE 5 WORD PROCESSING. Starting Microsoft Word To load Microsoft Word: 1. Click on the Start menu in the bottom left corner of the screen 2. Choose.
COMPREHENSIVE Windows Tutorial 3 Personalizing Your Windows Environment.
 Options Menu ◦ The primary collection of menu items for an activity, which appears when the user touches the MENU button. When your application is running.
Cosc 5/4730 Android Navigation: Menus, ActionBar/ToolBar, and Navigation Drawer.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
XP Exploring the Basics of Microsoft Windows XP1 Exploring the Basics of Windows XP.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
© The McGraw-Hill Companies, 2006 Chapter 18 Advanced graphics programming.
Exploring the Basics of Windows XP. Objectives Start Windows XP and tour the desktop Explore the Start menu Run software programs, switch between them,
Cosc 4755 Phone programming: GUI Concepts & Threads.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Development (Basics)
Exploring the Basics of Windows XP
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus.
UBUNTU - Desktop Panel by default is across the top Applications menu Quick Launch icons Notification area Clock Shut Down Task Bar by default is on the.
Microsoft Wang Li, Wang Yini, Li YIcheng.  This is a presentation about Microsoft Windows7 guidelines  Wang Li K8wali00  Li Yicheng K8liyi00  Wang.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
CIS—100 Chapter 15—Windows Vista 1. Parts of a Window 2.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
Lập trình trên Windows với Microsoft®.NET Giảng viên : Hồ Hoàn Kiếm.
Microsoft Access Lesson 1 Lexington Technology Center February 11, 2003 Bob Herring On the Web at
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
Office  The following are basic components of the MS Office document screens in the Windows environment. Some tabs and/or tools will change depending.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © Curt Hill Java Looking at our first console application in Eclipse.
XP New Perspectives on Windows XP Tutorial 1 Exploring the Basics.
Information Technology Word Processing. Word Processing is the preparation of documents such as letters, reports, memos, books, or any other type of correspondences.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
BlackBerry Event Handling. Overview Introduction Typical Application Model Event Listeners Responding to UI Events Touch Screen Events Touch Screen Gestures.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Copyright© Jeffrey Jongko, Ateneo de Manila University Editing ListAdapter Data part 2.
Action Bar Action Bar Contains Logo Application Name Options Menu SW in Android 3.0 and above was HW in Older Versions.
By Felixberto Dominic B. Eruela.  Using a computer to create, edit, and print documents. Of all computer applications, word processing is the most common.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Styles, Dialog Boxes, and Menus. Styles Allow creation of a common format – placed in res/values/styles.xml – file name is incidental Can be applied.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Lesson 1 - Understanding the Word Window and Creating a New Document
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Android Application Lifecycle and Menus
Getting to Know Your Desktop Icons, Taskbar, Workspace, Window, Notifications, Start and Search.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
Chapter 5 Menus, Sub Procedures and Sub Functions Programming In Visual Basic.NET.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Lecture 8 the Preference Menu. Settings... Sudoku settings s Music Play background music Hints Show hints during play We add some strings to the strings.xml.
XP New Perspectives on Microsoft Windows XP Tutorial 1 1 Microsoft Windows XP Creating a Web Site Tutorial 1.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
Menus. Menus are a common user interface component in many types of applications. The options menu is the primary collection of menu items for an activity.
Windows Tutorial 3 Personalizing Your Windows Environment
Lab7 – Appendix.
Android Programming - Features
CS240: Advanced Programming Concepts
Customizing the Quick Access Toolbar in Microsoft Office
GUI Programming Fundamentals
GUI Components Part II.
Politeknik Elektronika Negeri Surabaya
Mobile Application Development BSCS-7 Lecture # 11
PC02 Term 1 Project Basic Messenger. PC02 Term 1 Project Basic Messenger.
Android Developer Fundamentals V2 Lesson 4
Objects First with Java
Presentation transcript:

Cosc 5/4730 Blackberry and Android: Menus

BLACKBERRY

Menu With a MainScreen, you are provided a menu – It has a default Close item, which calls the onClose() method If you don’t override it, then it just closes the screen. – You are provided with 3 methods addMenuItem(MenuItem item) removeMenuItem(MenuItem item) removeAllMenuItems()

Menu (2) You can add your own menu items, by creating a MenuItem – It’s runnable to you must have a run() method. Example: MenuItem getset = new MenuItem("Get Settings", 1,100) { 1 is ordinal - Ordering parameter, lower values are placed closer to the top of the menu screen 100 is the priority of the menu item. A lower value indicates a higher priority public void run() { gettingsettings(); } }; addMenuItem(getset); //this method is from the MainScreen

makeMenu method The second method to add, change, customize the menu is override the MakeMenu method. protected void makeMenu(Menu menu, int instance) { super.makeMenu(menu,instance); //m1 is MenuItem variable menu.add(MenuItem m1); menu.addSeparator(); … }

makeMenu method (2) In API – You can customize the background, border and font of the menu Using Menu.SetBackground, Menu.setborder, and menu.SetFont – You can also add menu icons, using the MenuItem.setIcon method. Don’t need to override makeMenu to add and icon – getset.setIcon(Image menuIcon);

Submenus and popup menus are available in API – In the net.rim.device.api.ui.menu package. Create a “submenu”, – then add it to the menu. protected void makeMenu( Menu menu, int instance ) { SubMenu statusSubMenu = new SubMenu(null,"My Status",300,3); statusSubMenu.add(_status1); statusSubMenu.add(_status2); menu.add(statusSubMenu); super.makeMenu(menu, instance); };

popup menus You can also create context popup menus Except I can’t get the Example code to show a Popup menu.

ToolBars Toolbars provide users with a quick and easy way to access frequent actions for an application or screen. Each toolbar consists of a set of icons that appears along the bottom of the screen. – API – Convention says the icons should be no more then 33x33 – But example shown is obviously using much wider icons.

Toolbar example Simple some code (see the example on hand outs) Create a ToolbarManager ToolbarManager manager = new ToolbarManager(); setToolbar(manager); Create ToobarButtonField ToolbarButtonField button1 = new ToolbarButtonField(myImage, new StringProvider("butn1")); Add commands to button (code skipped) Add the ToobarButtonField to the manager manager.add(button1);

ANDROID

Menu By default, every Activity supports an options menu of actions or options. You can add items to this menu and handle clicks on your additions The easiest way to add menu items is override onCreateOptionsMenu(Menu menu) and onOptionsItemSelected(MenuItem)

onCreateOptionsMenu create IDs for the menu items, need them later to find out which menu was selected. protected static final int Menu1_ID = Menu.FIRST; protected static final int Menu2_ID = Menu.FIRST+1; Override and add the menu items you public boolean onCreateOptionsMenu(Menu menu) { add(int groupId, int itemId, int order, CharSequence) menu.add(0, Menu1_ID, 0, "Menu 1"); menu.add(0, Menu2_ID, 0, "Menu 2"); return super.onCreateOptionsMenu(menu); }

onCreateOptionsMenu (2) You can also add sub menu as well – addSubMenu performShortcut(int keyCode, KeyEvent event, int flags) – Execute the menu item action associated with the given shortcut character. removeGroup(int groupId) – Remove all items in the given group. removeItem(int id) – Remove the item with the given identifier. clear() – Remove all existing items from the menu, leaving it empty as if it had just been created.

public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case Menu1_ID: //do something return true; //we processed the menu item case Menu2_ID: //do something return true; default: //super does something. return super.onOptionsItemSelected(item); }

Menu Example You can add 5 menu items and the they will stack. With 6 or more menu items, you will get a MORE menu item So put the important menu items as the first ones and the least important (used) farther down.

JellyBean and menus Starting in ICS (v3), you can use a xml layout – Also create context or popup menus A note they are differences between v3 and v4. I’m ignoring v3 and using v4. – First create a menu xml (normally in res.menu) with menu as the type. You can add items (and sub menus). You can also group the items as well.

Xml example: <item android:orderInCategory="5" android:title="item1"/> <item android:orderInCategory="10" android:title="item2"/> <item android:orderInCategory="1" android:title="item3"/> <item android:orderInCategory="3" android:title="item4"/> <item android:orderInCategory="2" android:title="item5"/> Note the orderInCategory determines the order of display, so this will show: Item3 Item5 Item3 Item1 item2

Java code This is all that is needed for onCreateOpensMenu – No constants are needed public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menuv4, menu); return true; }

onOptionsItemSelected Use the R.id.X instead of constants. switch (item.getItemId()) { case R.id.item1: //do something return true; …

Popup menus. Add a click listener (or longtouch, whatever) to anything. – We are using a TextView, so make sure it clickable – It will then call our code, called showPopupMenu(View v) Note this is not an override, just a method we are using public void onClick(View v) { showPopupMenu(v); }

showPopupMenu private void showPopupMenu(View v){ PopupMenu popupM = new PopupMenu(this, v); popupM.inflate(R.menu.popup); popupM.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() public boolean onMenuItemClick(MenuItem item) { //do something return true; } }); popupM.show(); }

Example Using the menu Using the popup menu

code The code for these examples is on the web pages Blackberry: menu Demo.zip Android: menuV2.zip and menuV4.zip

Q A &