Session7 J2ME High Level User Interface(HLUI) part1-2
-
Upload
muthusvm -
Category
Technology
-
view
860 -
download
2
description
Transcript of Session7 J2ME High Level User Interface(HLUI) part1-2
Outline-session 7 (09-April-2009)
>> High-Level User Interface: Part I-Image and Image Item-List-Text- Alert and Alert Type- Ticker
Image and ImageItem
>>Using imageItem class we can decide how should image display on a form.
>> Centered Horizontally to the left or to the right.>> Image Layout.>>Left screenshot:LAYOUT_NEWLINE_BEFORE |
LAYOUT_CENTER | LAYOUT_NEWLINE_AFTER
>>Right screenshot: LAYOUT_NEWLINE_BEFORE | LAYOUT_LEFT | LAYOUT_NEWLINE_AFTER
Image and ImageItem
>>Left screenshot:LAYOUT_NEWLINE_BEFORE | LAYOUT_RIGHT | LAYOUT_NEWLINE_AFTER.
>> Right screenshot: No Directives
Image Class
>>Image on Mobile device come on two flavors:>>Immutable Image:
-Image cannot be changed.- Immutable image are created from image file , or content stored in the database.-It can be placed on the Form, Choice Group, Item,Alert.
>>Mutable Image:-Provides ultimate flexibility.- allocating chunck of memory for create or draw image.-we can draw Immutable image using paint() method its in Canvas Class.
Image and ImageItem
Image Layout
>>Image Layout is decide how should image appear in a mobile device
>>Layout is done by ImageItem class >> Example ImmutableImageFromFile.java
Choice Group with Image.java ReadDisplayFile.java
ImageItem API
Layout Directives
Logical operation with Directive
ImageItem.LAYOUT_RIGHT 00000000 00000010ImageItem.LAYOUT_CENTER 00000000 00000011
----------------------------logical OR 00000000 00000011
ImageItem.LAYOUT_CENTER 00000000 00000011ImageItem.LAYOUT_NEWLINE_BEFORE 00000001 00000000
------------------logical OR 0000000 1 00000011Mask off upper 8 bits 11111111 00000000
------------------logical AND 00000001 00000000
List>>List are three format.>> Multiple , Exclusive, Implicit>> Example:ImplicitList,MultipleChoiceList
Event Handling for List
>>Exclusive and Multiple List:- No event is generated when a user changes a list element.-To determine the status of the various elements, you will need a break in the action(Command).- For example, you may have a multiple-selection list on the screen with various application preferences. When a user chooses to "Save," you could write the preferences to persistent storage.
>> Implicit List:- event is immediately generated- exclusive and multiple, the method commandAction() will be called
Choice Group Vs List>>Similarity
-Both implement the Choice interface. This interface defines a common set of methods : adding, deleting and getting elements, to name just a few.- Both can show explicit choices (radio buttons) or multiple choices (check boxes).
>>Difference -Appearance
*A ChoiceGroup appears as part of a Form.* A List occupies the display as a single entity
Choice Group Vs List>>Difference -Implementation-=- ChoiceGroup can have the following types:
MULTIPLE: Any number of elements can be selected (Checkbox)EXCLUSIVE: One element is selected at any given time (Radio Group)
-=- List can have the following types: MULTIPLE: Any number of elements can be selected (Checkbox)EXCLUSIVE: One element is selected at any given time (Radio Group)IMPLICIT: Selection of an element generates an event (Menu)
-=-Event processing for a ChoiceGroup can use either an ItemStateListener to detectchanges, which will result in a call to the method itemStateChanged().
-=- With a list you also have the option to use a Command object to initiate an event
List API
TextBox
>>A TextBox is a multi-line text entry screen>> we can restrict how many characters you would like the
TextBox to hold.>> SimpleClipBoard.java
TextBox Vs TextField
>>Similarity --Both share the input constraints as specified in the TextField
class.-- Both have a maximum capacity that may be different than
what can be displayed on the device at any one time. Scrolling will be provided by the implementation as necessary
>>Difference Appearance:
-A TextField is a subclass of Item, and therefore appears as part of a Form-A TextBox is the only component visible
TextBox Vs TextField
>>Difference Implementation:
-TextField, you can use an ItemStateListener to detect changes that will result in a call to the method itemStateChanged()-TextBox events are handled exclusively through Command objects.
TextBox API
Alert and AlertType
>>Alert- Alert is simple dialog box that will support both Image and Text.-Use of Alert is to show a warning or error message.-we can control the three visual attribute title,Image,Text
>> Limitation-Command object is not allowed in the Alert.-User interaction is entirely managed by the implementation.-Can’t add TextField or TextBox.
Alert and AlertType
>>Types of AlertThere are two type of Alerts.1.Modal-The Alert is on the display until a user dismisses it.2.Timed-The Alert is on the display for the specific no., of MS.
>> Default alert for Device.--getDefaultTimeout()- A return value equivalent to Alert.FOREVER indicates modal
>> Value DescriptionFOREVER Specifies the Alert is visible until acknowledged by the user (also known as modal).
Alert and AlertType
>>Alert Implementation:Alert al;al = new Alert("Error", "Error Message ", null, null);al.setTimeout(Alert.FOREVER);>> two methods in the Display class to show the Alert
1. display.setCurrent(alTest, fmMain);2. display.setCurrent(alTest);
Alert API
Alert and AlertType sound support
>> In addition to the visual attributes, you can associate a sound with an Alert
>> There are five pre-define sound that tide with various condition-error, warning, information, confirmation, alarm
>> Play sound in two way1. al = new Alert("Alert", "Message ", null,AlertType.WARNING);al = new Alert("Alert", "Message ", null, null);...al.setType(AlertType.WARNING);2. AlertType.INFO.playSound(myDisplay);
>>Example SoundAlert.java>>ModalAlert.java
Ticker
>> Ticker can be "attached" to any Screen, including an Alert.>> same Ticker can be shared among Screens, giving the illusion
that the Ticker is attached to the device display>> Ticker API>>Example :SharedTicker.java