import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ListImage extends MIDlet implements CommandListener{
private Display display;
private List list;
private Command exit, next;
private Image car, plane, hotel, mob;
String[] s = {"Aero plane", "Car", "Mobile"};
public ListImage(){
try{
plane = Image.createImage("/suhas8.jpg");
car = Image.createImage("/suhas8.jpg");
mob = Image.createImage("/suhas8.jpg");
}catch(Exception e){
//System.err.println(e.getMessage());
}
}
public void startApp() {
display = Display.getDisplay(this);
Image[] i = {airplane, car, mobile};
list = new List("List + Image", List.IMPLICIT, s, i);
next = new Command("Select", Command.SCREEN, 0);
exit = new Command("Exit", Command.EXIT, 0);
list.addCommand(next);
list.addCommand(exit);
list.setCommandListener(this);
display.setCurrent(list);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional){
notifyDestroyed();
}
public void commandAction(Command c, Displayable s){
int index = list.getSelectedIndex();
if (c == next || c == List.SELECT_COMMAND) {
Alert alert=new Alert("selected","u r selected",list.getImage(index),null);
display.setCurrent(alert, list);
} else if(c == exit){
destroyApp(true);
}
}
}
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ListImage extends MIDlet implements CommandListener{
private Display display;
private List list;
private Command exit, next;
private Image car, plane, hotel, mob;
String[] s = {"Aero plane", "Car", "Mobile"};
public ListImage(){
try{
plane = Image.createImage("/suhas8.jpg");
car = Image.createImage("/suhas8.jpg");
mob = Image.createImage("/suhas8.jpg");
}catch(Exception e){
//System.err.println(e.getMessage());
}
}
public void startApp() {
display = Display.getDisplay(this);
Image[] i = {airplane, car, mobile};
list = new List("List + Image", List.IMPLICIT, s, i);
next = new Command("Select", Command.SCREEN, 0);
exit = new Command("Exit", Command.EXIT, 0);
list.addCommand(next);
list.addCommand(exit);
list.setCommandListener(this);
display.setCurrent(list);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional){
notifyDestroyed();
}
public void commandAction(Command c, Displayable s){
int index = list.getSelectedIndex();
if (c == next || c == List.SELECT_COMMAND) {
Alert alert=new Alert("selected","u r selected",list.getImage(index),null);
display.setCurrent(alert, list);
} else if(c == exit){
destroyApp(true);
}
}
}
No comments:
Post a Comment