My J2ME Programming Exercise (1) - List

xiaoxiao2021-03-05  25

Import javax.microedition.lcdui. *; import javax.microedition.midlet. *;

public class listtest extends MIDlet implements CommandListener {private List alist; private Command exitcommand; private Command okcommand; private Display adisplay; private Alert analert; public listtest () {analert = new Alert ( "Selected", "You have Choose a Fruit", NULL, ALERTTYPE.INFO;

Alist = new list ("fruit", choice.multiple; eXitcommand = new command ("exit", command.exit, 1); okcommand = new command ("ok", command.ok, 1); alist.append ( "Apple", NULL; Alist.Append ("Orange", NULL); Alist.Append ("Banana", NULL); alist.addcommand; alist.addcommand (OkCommand); alist.setcommandlistener (this); } public void startApp () {adisplay = Display.getDisplay (this); adisplay.setCurrent (alist);} public void pauseApp () {} public void destroyApp (boolean unconditional) {} public void commandAction (Command c, Displayable d) {// use the i get the Selected list element // int i = alist.getSelectedIndex (); if (c == exitcommand) {destroyApp (false); notifyDestroyed ();} else {// display different information when diffenent element // have been selected / * if (i == 0) { Analert.setString ("You Have Choosed Apple!"); Adisplay.SetCurrent (Analert, Alist);} if (i == 1) {Analert.setstring ("You Have Choosed Orange!"); Adisplay.SetCurrent (Analert, Alist);} if (i == 2) {Analert.SetString ("You Have Choosed Banana!"); Adisplay.SetCurrent (Analert, Alist);} * / string s = ""; for (int i = 0; I

转载请注明原文地址:https://www.9cbs.com/read-35502.html

New Post(0)