Session7 J2ME High Level User Interface(HLUI) part1-2

24
Outline-session 7 (09-April- 2009) >> High-Level User Interface: Part I -Image and Image Item -List -Text - Alert and Alert Type - Ticker

description

Session7 HLUI Part1-2

Transcript of Session7 J2ME High Level User Interface(HLUI) part1-2

Page 1: 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

Page 2: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 3: Session7 J2ME High Level User Interface(HLUI) part1-2

Image and ImageItem

>>Left screenshot:LAYOUT_NEWLINE_BEFORE | LAYOUT_RIGHT | LAYOUT_NEWLINE_AFTER.

>> Right screenshot: No Directives

Page 4: Session7 J2ME High Level User Interface(HLUI) part1-2

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.

Page 5: Session7 J2ME High Level User Interface(HLUI) part1-2

Image and ImageItem

Page 6: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 7: Session7 J2ME High Level User Interface(HLUI) part1-2

ImageItem API

Page 8: Session7 J2ME High Level User Interface(HLUI) part1-2

Layout Directives

Page 9: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 10: Session7 J2ME High Level User Interface(HLUI) part1-2

List>>List are three format.>> Multiple , Exclusive, Implicit>> Example:ImplicitList,MultipleChoiceList

Page 11: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 12: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 13: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 14: Session7 J2ME High Level User Interface(HLUI) part1-2

List API

Page 15: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 16: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 17: Session7 J2ME High Level User Interface(HLUI) part1-2

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.

Page 18: Session7 J2ME High Level User Interface(HLUI) part1-2

TextBox API

Page 19: Session7 J2ME High Level User Interface(HLUI) part1-2

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.

Page 20: Session7 J2ME High Level User Interface(HLUI) part1-2

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).

Page 21: Session7 J2ME High Level User Interface(HLUI) part1-2

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);

Page 22: Session7 J2ME High Level User Interface(HLUI) part1-2

Alert API

Page 23: Session7 J2ME High Level User Interface(HLUI) part1-2

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

Page 24: Session7 J2ME High Level User Interface(HLUI) part1-2

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