救命!List列出图像名后,选择后怎么显示?<可以进行选择了,不会显示>
//list.java
//这个程序是很臭的
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class list extends MIDlet implements CommandListener {
private Display display;
private Form form;
private List list;
private Alert alert;
private TextBox textbox;
private Image image;
public list() {
// TODO 自动生成构造函数存根
form=new Form( "Form ");
list=new List( "List ",List.TEXT_WRAP_ON);
alert=new Alert( "Alert ", "警告! ",null,null);
try{
image=Image.createImage( "/ai.png ");
}
catch(Exception e)
{
}
textbox=new TextBox( "TextBox ", "文本 ",256,0);
display=Display.getDisplay(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO 自动生成方法存根
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void startApp() throws MIDletStateChangeException {
// TODO 自动生成方法存根
display=Display.getDisplay(this);
display.setCurrent(list);
list.setCommandListener(this);
list.append(new String( "爱 "),image);
list.append(new String( "爱 "),image);
//list.set(1,new String( "爱 "), image);
}
public void commandAction(Command c,Displayable d)
{
if(d.equals(list))
{
if(c==list.SELECT_COMMAND)
{
list.getSelectedIndex();
display.setCurrent(list);
list.append(null, image);
}
}
}
}
------解决方案--------------------用switch语句