PROG 38448 Mobile Java Application Development PROG 38448 Mobile Java Application Development Event Handling Creating Menus.

Slides:



Advertisements
Similar presentations
ProgressBook User Start-Up
Advertisements

Prof. Yitzchak Rosenthal
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Computer Basics Hit List of Items to Talk About ● What and when to use left, right, middle, double and triple click? What and when to use left, right,
Microsoft Office XP Microsoft Excel
Customizing the MOSS 2007 Search Results November 2007 Rafael Perez.
CPIT 102 CPIT 102 CHAPTER 1 COLLABORATING on DOCUMENTS.
Loading Excel Double click the Excel icon on the desktop (if you have this) OR Click on Start All Programs Microsoft Office Microsoft Office Excel 2003.
Homework 1 Hints. Homework Tips (General) Go through and do the ENTIRE homework in the same time period – You will use all of the material from chap 1.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Cosc 5/4730 Blackberry and Android: Menus. BLACKBERRY.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Cosc 4755 Phone programming: GUI Concepts & Threads.
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
© 2009 Research In Motion Limited User interface design for mobile devices.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
CST JavaScript Validating Form Data with JavaScript.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
StressChill App Click the StressChill icon (shown to the right) to open the app. If you do not see this on the desktop, you will find it in the pull up.
Visual Basic Chapter 1 Mr. Wangler.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Managing Business Data Lecture 8. Summary of Previous Lecture File Systems  Purpose and Limitations Database systems  Definition, advantages over file.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.
MICROSOFT WORD GETTING STARTED WITH WORD. CONTENTS 1.STARTING THE PROGRAMSTARTING THE PROGRAM 2.BASIC TEXT EDITINGBASIC TEXT EDITING 3.SAVING A DOCUMENTSAVING.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
PROG Object Oriented Programming II PROG Object Oriented Programming II Window Events Multi-screen Applications.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Instructions and Reporting Requirements Module 7 Electronic Reporting For Facilities March 2014 North Carolina Central Cancer Registry State Center for.
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry API for UI Applications.
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
Designing Interface Components. Components Navigation components - the user uses these components to give instructions. Input – Components that are used.
XP 1 Microsoft Word 2002 Tutorial 1 – Creating a Document.
GUI Widgets Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
Teacher’s Assessment Assistant Worksheet Builder Starting the Program
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter 1 - Getting to know Greenfoot
BlackBerry Event Handling. Overview Introduction Typical Application Model Event Listeners Responding to UI Events Touch Screen Events Touch Screen Gestures.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
The Next Generation. Parent Access Grade History and Attendance.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Concurrent Programming and Threads Threads Blocking a User Interface.
Applications Development
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Blackboard 8: Grade Center This workshop is for existing users of Blackboard interested in keeping track of student grades online. Blackboard replaced.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
Oct 021 Outline What is a widget? Buttons Combo boxes Text components Message boxes.
SYST Web Technologies SYST Web Technologies XHTML Forms.
Lesson 1 - Understanding the Word Window and Creating a New Document
PROG Mobile Java Application Development PROG Mobile Java Application Development Data Storage, Continued.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Homework 2 Hints. General Tips Remember what FORM view you are in! – Design, form, and layout view TABLE views include: – Design and Datasheet view.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Chapter 5 Validating Form Data with JavaScript
Android – Event Handling
PC02 Term 1 Project Basic Messenger. PC02 Term 1 Project Basic Messenger.
Creating Forms on a Web Page
Constructors, GUI’s(Using Swing) and ActionListner
Presentation transcript:

PROG Mobile Java Application Development PROG Mobile Java Application Development Event Handling Creating Menus

8/28/2015Wendi Jollymore, ACES2 Review Recall that we created this application:

8/28/2015Wendi Jollymore, ACES3 Event Handling BlackBerry uses a Unicast Event model Each field can have only one listener Unlike desktop apps where a component can trigger multiple events If you try to register with more than one listener, you replace previous listener with new one Remember mobile devices have limited resources

8/28/2015Wendi Jollymore, ACES4 FieldChangeListener FieldChangeListener interface net.rim.device.api.ui.FieldChangeListener fieldChanged(Field field, int context) event handler method Field field –the field that triggered event int context – depends i.e. for custom fields can be used to send extra data Your screen class should implement this interface And obviously override fieldChanged() method Field.setChangeListener(listener) Registers a component with the event listener

8/28/2015Wendi Jollymore, ACES5 Add Event Handling Add event handling to your application: Reset should clear all fields Create and invoke a clearFields() method Reset all textboxes so that they’re empty Reset the date field to the current date “Assignment” should be selected in the radio button group

8/28/2015Wendi Jollymore, ACES6 Add Event Handling Submit button Create and invoke a submit() method Grab the grade and the max grade value from the text fields Both grade and max grade must be greater than or equal to 0 Calculate percentage grade / max * 100 Display in percentage label You can make this better with error handling, formatting, etc. See the notes for hints and tips

8/28/2015Wendi Jollymore, ACES7 Program Exit Recall that we never use System.exit() for exiting a mobile app MainScreen has close() and onClose() methods By default onClose() will call onSavePrompt() if screen is “dirty” Dirty means field data was changed We don’t need this functionality Default is to display the Save/Discard/Cancel dialog

8/28/2015Wendi Jollymore, ACES8 Program Exit public boolean onClose() { Dialog.alert("Exiting. Thanks!"); close(); return true; } Override onClose() method: Display an exit dialog alert Call close() method close() will pop the screen off the stack and, if stack is empty, will terminate the application

8/28/2015Wendi Jollymore, ACES9 Creating Menus net.rim.device.api.ui.MenuItem The class that models the menu items you click on to perform actions Implements Runnable interface This is used for creating threads or adding “activity” to classes Contains a run() method you must override Will run on main event thread, so this is where you put your event handling code for menu items Don’t do anything heavy in run() !!

8/28/2015Wendi Jollymore, ACES10 Creating Menus MenuItem constructor requires 3 things: Menu text Ordinal Where this item appears in the menu in relation to other menu items Higher ordinals near the bottom, lower ordinals near the top Priority What item is highlighted as default when menu opens Lowest priority item is highlighted

Creating Menus new MenuItem(“Reset”, 10, 20) new MenuItem(“Calculate”, 20, 10) 8/28/2015Wendi Jollymore, ACES OrdinalPriority

8/28/2015Wendi Jollymore, ACES12 Creating Menus To create a menu, override the MenuItem class Can use named inner class Can use anonymous inner class This is most popular Only use the menu item once! Default constructor should call super(menuText, ordinal, priority) To pass on the 3 values run() method contains event handler code

8/28/2015Wendi Jollymore, ACES13 Creating Menus private class ClearMenuItem extends MenuItem { public ClearMenuItem() { super("Clear", 10, 20); } public void run() { clearTextFields(); } }

8/28/2015Wendi Jollymore, ACES14 Creating Menus Next, you override MainScreen.makeMenu() method Adds a little more flexibility in app Invoked automatically when user does something to bring up a menu Overriding it allows us to customize the default menu makeMenu(Menu menu, int instance) Menu = the main menu you’re adding to instance = which context you’re using BlackBerry menus vary depending on context Where user clicked to get menu, if something was selected or not Constants define the different options

8/28/2015Wendi Jollymore, ACES15 Creating Menus makeMenu(), instance param, continued Menu.INSTANCE_CONTEXT menu displayed by clicking trackball (or touch menu button w/touch screen devices) usually context sensitive - just a few items off main menu that are relevant to object which had the focus automatically includes a "Full Menu" item so user can click this to get the full menu instead (Menu.INSTANCE_DEFAULT)

8/28/2015Wendi Jollymore, ACES16 Creating Menus makeMenu(), instance param, continued Menu.INSTANCE_CONTEXT_SELECTION same as above, but displayed when text is selected use for items that apply to selected/copied text Menu.DEFAULT menu is displayed when Menu key is pressed should contain all items in context menu plus items that apply to entire application Always call super.makeMenu() first inside method Keeps the default Close item and its functionality

8/28/2015Wendi Jollymore, ACES17 Creating Menus protected void makeMenu(Menu menu, int instance) { super.makeMenu(menu, instance); menu.add(new LoginMenuItem()); menu.add(new ClearMenuItem()); }

8/28/2015Wendi Jollymore, ACES18 Creating Menus You can also do this with anonymous inner classes instead of named inner classes A bit messier, but saves on resources for a mobile device protected void makeMenu(Menu menu, int instance) { super.makeMenu(menu, instance); menu.add(new MenuItem("Clear", 10, 20) { public void run() { clearTextFields(); } }); }

8/28/2015Wendi Jollymore, ACES19 Best Practices for Menu Implementation Always provide a full menu. Make sure that users can press the Menu key to open the full menu and to initiate an action when a menu item is highlighted. Make sure that users can also hold the Menu key to open the dialog box for switching applications. For the default menu item, use the menu item that users are most likely to select. Place the default menu item and other common menu items in the middle of the menu.

8/28/2015Wendi Jollymore, ACES20 Best Practices for Menu Implementation Verify that the order of menu items is consistent with the order of menu items in other BlackBerry device applications. Group menu items according to common usage or common functionality, and where possible, test your groupings with users. Insert separators between menu item groupings. Do not place menu items for conflicting actions close together. For example, do not place a "Delete" menu item beside an "Open" menu item.

8/28/2015Wendi Jollymore, ACES21 Best Practices for Menu Implementation Always include the "Switch application" and "Close" menu items. Place these menu items at the end of the menu. If you use standard components, these menu items are included automatically. Guidelines for menu labels: Use concise, descriptive labels that are no longer than 12 characters. If a label is too long, an ellipsis (...) appears to indicate that the text is truncated. Use verbs for labels. Use title case capitalization for labels.

8/28/2015Wendi Jollymore, ACES22 Best Practices for Menu Implementation Guidelines for menu labels, continued: Use an ellipsis in a menu item label to indicate that users must perform another action after they click the menu item. For example, if users click the Go To Date... menu item in the calendar, they must specify a date on the screen that appears. Avoid using symbols such as an asterisk (*) in labels.

8/28/2015Wendi Jollymore, ACES23 Add Menus to App Add menu items for “Reset” and “Submit” to your application. Hopefully you paid attention to instructions earlier Call your methods from earlier in the run() method E.g. to clear fields and calculate percentage

8/28/2015Wendi Jollymore, ACES24 Exercises and Homework Do Assignment #2 It’s on the web