Slides for this Lesson

Download Report

Transcript Slides for this Lesson

PROG 38448
Mobile Java Application
Development
BlackBerry API for UI Applications
BlackBerry API for UI
What is the purpose of a GUI in an
application?
Relationship between app and user
Provide information in a user-friendly
way
Easy to read
Intuitive
Familiar
4/8/2016
Wendi Jollymore, ACES
2
BlackBerry API for UI
Which UI API to use?
BlackBerry Java App:
BlackBerry Java UI API
Always extends UiApplication and starts with
main()
And probably MIDP API and CLDC API
MIDlet
An app that uses the MIDP UI API
Can run on any device that uses Java ME
4/8/2016
Wendi Jollymore, ACES
3
BlackBerry UI API Advantages
Provide more functionality for BB devices than
just MIDP API
Can run background threads after app closes
Can start automatically in the background when
device turns on
Can use IPC (Inter-Process Communications)
APIs to send and rec’v information
Can access trackball and trackwheel events
Can access touch screen events
Can access and use accelerometer data
Can integrate with other BB apps
Can change home screen icon for your app
4/8/2016
Wendi Jollymore, ACES
4
BlackBerry UI API Disadvantages
BlackBerry APIs can only be used
on a BlackBerry device.
4/8/2016
Wendi Jollymore, ACES
5
UI Guidelines
Consider limitations of mobile devices:
Small screen size, limited # of characters
Slower processor
Wireless network – slower, longer delays
Small amount of memory
Short battery life
Can only display one screen at a time
Users expect smaller amounts of
information quickly
BlackBerry UI was designed with this in mind
4/8/2016
Wendi Jollymore, ACES
6
UI Guidelines
Be consistent
Use or extend existing components
Allows you to inherit default behaviour
Follow standard navigation model
Actions are the same for all apps
Support and extend user tasks
Help user perform tasks easily e.g. autodetect location if your app is locationbased
BlackBerry users are familiar with how
BlackBerry UIs work!
4/8/2016
Wendi Jollymore, ACES
7
UI Guidelines
Focus on user’s task
Only display data/components that are
relevant to the task at hand
Make selection of data simple
Make menu items relevant and in
context
E.g. for an app that searches for
hotels, a “search” or “start over” item
would be relevant, but a “delete” item
might not be
4/8/2016
Wendi Jollymore, ACES
8
UI Guidelines
Minimize clicks needed to complete
a task
Allow for “Undo”
It’s easier on a small screen to click
the wrong thing by accident
Design your display for the small
screen
4/8/2016
Wendi Jollymore, ACES
9
UI Input and Action Triggers
Devices contain standard input methods:
Keyboard
Trackball or track pad
Track wheel
Escape key
Touch screen
See more in Section
2 of the UI &
Navigation
Development Guide
Standard behavior:
Clicking trackball, track wheel, track pad or
touch screen invokes a menu item or
application icon
Escape cancels current operation or returns
to previous screen
4/8/2016
Wendi Jollymore, ACES
10
UI Components
Three main components that make up a
UI:
Screen
Display, layout
Menu
Standard behavior when user clicks or Escapes
Managers
Arranges components in a specific way
Like Java SE layout mangers
Fields
Standard UI elements like buttons, labels, text
fields, radio buttons, check boxes, etc.
4/8/2016
Wendi Jollymore, ACES
11
UI Components
Screens contain Managers, Managers
contain Fields
Screen Object
Manager Object
Component
4/8/2016
Wendi Jollymore, ACES
12
Screen Class
net.rim.device.api.ui.Screen
Starting point for the GUI
Only one screen can be displayed at a time
Screen display stack
Screens are displayed by pushing and
popping them on/off the display stack
Only the screen on top of the stack is seen
A screen can exist only once in the stack
net.rim.device.api.ui.container
Common subclasses of Screen class
Check this out in the api docs
4/8/2016
Wendi Jollymore, ACES
13
MainScreen Class
A child of Screen (via FullScreen)
Contains standard UI components:
Default screen title
Scrollable VerticalFieldManager
Default menu with Close item
Default action for Close menu item and
escape key
Most BlackBerry apps’ screens are
extended from MainScreen
4/8/2016
Wendi Jollymore, ACES
14
Manager Class
net.rim.device.api.ui.Manager
Manages the layout of the components of
your UI
And how the components react when
laid out near each other
Just like layout mangers in Java SE
Every screen object contains at least one
manager
net.rim.device.api.ui.container
Some common sub classes of Manager
4/8/2016
Wendi Jollymore, ACES
15
Manager Examples
VerticalFieldManager
Lays out fields in a single column
Can be constructed with horizontal or
vertical scroll
Manager.HORIZONTAL_SCROLL or
Manager.VERTICAL_SCROLL
FlowFieldManager
Like the Java SE FlowLayout
Lays out components horizontally and
vertically like words on a page
Wraps to next line
4/8/2016
Wendi Jollymore, ACES
16
Field Class
net.rim.device.api.ui.Field
A rectangular region that displays
output to a user
Can also accept input
net.rim.device.api.ui.component
Contains pre-made component classes
Look this up in the api docs
4/8/2016
Wendi Jollymore, ACES
17
Field Examples
LabelField
A simple label with text
Text Field
A simple text field for inputting text
EditField
Simple text field that has its own label
RichTextField
Label field with formatting
ListField, ChoiceField,
RadioButtonField, CheckBoxField
DateField, ButtonField
4/8/2016
Wendi Jollymore, ACES
18
Exercise
See the Exercise section in the
notes
4/8/2016
Wendi Jollymore, ACES
19