Разработка мобильных приложений. Соколова В.В. - 89 стр.

UptoLike

Составители: 

89
private Alert timedAlert, modalAlert;
// The TextBox
private TextBox textBox;
// Command for exit the application
private Command exit = new Command("Exit", Command.EXIT,
0);
// Command for transition to the modal alert
private Command nextAlert = new Command("Next alert",
"Show next alert",
Command.OK, 0);
// Path to the image file
private static final String pathToImage = "images/alert-
image.png";
public void startApp() {
// Load the image
Image image = loadImage();
// Create the TextBox
textBox = new TextBox("", "", 120, TextField.ANY);
textBox.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable
d) {
if (c == exit) {
notifyDestroyed();
}
else if (c == nextAlert) {
textBox.setTitle("TextBox after modal
alert");
textBox.removeCommand(nextAlert);
display.setCurrent(modalAlert, textBox);
}
}
});
// Create the timed Alert
timedAlert = new Alert("Timed alert", "The alert is
going to be gone",
image, AlertType.INFO);
timedAlert.setTimeout(3000);
// Create the modal Alert
modalAlert = new Alert("Modal alert", "The alert is
waiting for action",
image, AlertType.WARNING);
modalAlert.setTimeout(Alert.FOREVER);
textBox.setTitle("TextBox after timed alert");
textBox.addCommand(exit);
textBox.addCommand(nextAlert);
// Make the timed Alert visible