Presentation is loading. Please wait.

Presentation is loading. Please wait.

J2ME Screen Hierarchy Displayable ScreenCanvas FormAlertListTextbox.

Similar presentations


Presentation on theme: "J2ME Screen Hierarchy Displayable ScreenCanvas FormAlertListTextbox."— Presentation transcript:

1 J2ME Screen Hierarchy Displayable ScreenCanvas FormAlertListTextbox

2 Form  A screen that contains arbitrary items  Selected methods: int append(Image img) int append(Item item) int append(String str) void insert(int itemNum, Item item) void delete(int itemNum) void deleteAll() Item get(int itemNum) void set(int itemNum, Item item) void setItemStateListener(ItemStateListener iListener) int size()

3 List  A screen that represents selection of choices  Types of List  List.MULTIPLE – selection of multiple options (checkboxes)  List.EXCLUSIVE – single-option selection only (radiobuttons) – selection is triggered via a command  List.IMPLICIT – single-option selection only – selection is triggered implicitly (List.SELECT_COMMAND)

4 IMPLICIT EXCLUSIVE MULTIPLE (SUN WTK Emulator)

5 IMPLICIT EXCLUSIVE MULTIPLE (Nokia S60 Emulator)

6 List  Creating Lists (List API) List(String title, int listType)  creates new, empty List, specifying its title and the type of the list List(String title, int listType, String[] stringElements, Image[] imageElements)  creates new List, specifying its title, the type of the List, and an array of Strings and Images to be used as its initial contents  best image width/height for List element Image Icon:  16x16 (WTK emulator)  57x41 (Nokia S60 3rd Ed FP 2 Emulator)  … –your phone? Display d = Display.getDisplay(this); int biw = d.getBestImageWidth(Display.LIST_ELEMENT); int bih = d.getBestImageHeight(Display.LIST_ELEMENT);

7 List  Selected methods int append(String stringPart, Image imagePart) -- append an element to the List void delete(int index) -- delete the element at the given index Image getImage(int index) -- gets the Image part of the given element String getString(int index) -- gets the String part of the given element int getSelectedFlags(boolean[] choices) -- returns the state of all elements (use with List.MULTIPLE) int getSelectedIndex() -- returns the index of an element in the List that is selected (use with List.IMPLICIT, List.EXCLUSIVE)

8 List Example  Creating List List payMethod = new List(“Payment method”, List.EXCLUSIVE); payMethod.append(“Credit Card”, null); payMethod.append(“PayPal”, null); payMethod.append(“Bank Acct”, null); okCmnd = new Command(“OK”, Command.OK, 1); payMethod.addCommand(okCmnd); payMethod.setCommandListener(...);  Processing Selection (in CommandListener) void commandAction(Command c, Displayable d) { if (c == okCmnd && d == payMethod) { int index = payMethod.getSelectedIndex(); if (index == CCARD) { }

9 List Appearance  Control with void setFitPolicy(int policy)  Choice.TEXT_WRAP_ON – long list items shown on multiple lines  Choice.TEXT_WRAP_OFF – truncate long list items to fit on one line  Choice.TEXT_WRAP_DEFAULT – use default policy (e.g. truncate with …)

10 Lab Exercise  Create an application that demonstrates the three types of List screen

11 Images  MIDP implementations required to support PNG format  Place image files in project resource folder – res/  Loading images Image logo = null; try { logo = Image.createImage(“/gburg.png”); } catch (IOException e) {... handle exception... }

12 Alert Screen  Intended for showing notification messages  Creating Alerts Alert(String title, String alertText, Image alertImage, AlertType alertType)  constructs a new Alert object with the given title, content, image, and type.  Alert types – WARNING, ERROR, INFO, CONFIRMATION  Screen sequencing and alerts Form receipt = new Form(“Receipt Details”); Alert confirm = new Alert(“Finished”, “The order is submitted!”, null, CONFIRMATION); Display.setCurrent(confirm, receipt);

13 Alert("ERROR Type", "Error condition notification!", null, AlertType.ERROR)

14 Alert("WARNING Type", "Warning condition notification!", null, AlertType.WARNING)

15 Alert("INFO Type", "Information message!", null, AlertType.INFO)

16 Alert("CONFIRMATION Type", "Confirm to proceed!", null, AlertType.CONFIRMATION)

17 Alert Screen  Selected methods Image getImage() -- gets the Image used in the Alert Gauge getIndicator() -- gets the activity indicator for this Alert String getString() -- gets the text string used in the Alert AlertType getType() – gets the type of the Alert int getTimeout() -- gets the time this Alert will be shown void setTimeout(int t) -- sets the time this Alert will be shown

18 Gauges  Used to show progress or get user input  Types of gauges  interactive – get user input (e.g. sliders)  non-interactive, continuous – show operation is executing  non-interactive, incremental – show progress (app should increment)

19 Gauges  Used to show progress or get user input  Types of gauges  interactive – get user input (e.g. sliders)  non-interactive, continuous – show operation is executing  non-interactive, incremental – show progress (app should increment) Gauge g1 = new Gauge("Interactive", true, 10, 5); Gauge g2 = new Gauge("Non-Interactive, Continuous", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); Gauge g3 = new Gauge("Non-Interactive, Incremental", false, Gauge.INDEFINITE, Gauge.INCREMENTAL_UPDATING);


Download ppt "J2ME Screen Hierarchy Displayable ScreenCanvas FormAlertListTextbox."

Similar presentations


Ads by Google