WEB开发网
开发学院WEB开发Jsp 《Java 手机/PDA 程序设计入门》读书笔记3--LCD... 阅读

《Java 手机/PDA 程序设计入门》读书笔记3--LCDAUI高级API之List

 2008-01-05 19:10:12 来源:WEB开发网   
核心提示:Screen类有四个子类: Alert List TextBox FormList根据Choice接口的定义,分为:Choice.Exclusive(单选)Choice.MULTipLE(多选)Choice.IMPLICIT(简易式的单选)单选型Image img=Image.createImage("/a.

Screen类有四个子类: Alert List TextBox Form

List根据Choice接口的定义,分为:Choice.Exclusive(单选)Choice.MULTipLE(多选)Choice.IMPLICIT(简易式的单选)

单选型Image img=Image.createImage("/a.png");List l=new List("List test",Choice.Exclusive);l.append("banana",img);l.append("apple",null);display.setCurrent(l);

insert()可在特定项目后插入一个新项目。set()可以重新设定某个项目。……System.out.PRintln("You have choice the"+l.getSelectedIndex()+"item.");System.out.println("the content is:"+l.getString(l.getSelectedIndex()));

多选型List l=new List("List test",Choice.MULTIPLE);……int size=l.size();for (int i=0;i<=size;i++){ if(l.isSelected(i)) { System.out.println("you have selected"+i); }}

getSelectedFlags()传回一个Boolean数组,借此可了解那个选项被选中。

简易式单选List l=new List("List test",Choice.IMPLICIT);……public void commandAction(Command c,Displayable s){if(c==List.SELECT_COMMAND){List tmp=(List)s;int i=tmp.getSelectedIndex();System.out.println("you have selected"+i)}……}

Choice.IMPLICIT在用户选择后,马上引发事件,并将List.SELECT_COMMAND通过commandAction()的第一个参数c传入。假如不希望这样,可以setSelectCommand(null)将它关掉,此时c=null.setSelectCommand(x)--x为另外一个Command对象,当List被选中后,x作为commandAction()的第一个参数传入。

setSelectCommand()后,这个Command--x会被addCommand()自动加到系统菜单。removeCommand(c)如同:setSelectCommand(null);removeCommand(c);

Choice接口提供的FitPolicy机制,决定当文字内容过长时,该如何处理Choice.TEXT_WRAP_ON-过长的文字自动换行Choice.TEXT_WRAP_OFF-过长的文字自动被截断Choice.TEXT_WRAP_DEFAULT-依照及其不同而不同,通常是前两种的一种

Tags:Java 手机 PDA

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接