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

UptoLike

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

93
private Command takeSongsCommand = new Command("Take",
Command.SCREEN, 0);
public void startApp() {
// Create all lists
createStore();
createFavoriteList();
createMenu();
// Start the app with the main menu
display.setCurrent(menuList);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
private void createStore() {
// Form the list of songs
String[] items = {
"Beethoven. Symphony No. 5: I",
"Tchaikovsky. 1812 Overture",
"Mozart. Eine Kleine Nachtmusik: Allegro",
"Bach. Toccata And Fugue In D Minor",
"Rossini. William Tell Overture",
"Pachelbel. Canon In D",
"Strauss. Blue Danube"
};
// Create the list
storeList = new List("Store", List.MULTIPLE, items,
null);
// Add the commands
storeList.addCommand(takeSongsCommand);
storeList.addCommand(gotoFavoriteCommand);
// Define the logic for commands
storeList.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable
d) {
if (c == takeSongsCommand) {
// Find selected items, remove them from the Store, and
// add them to the Favorites
boolean[] selected = new boo-
lean[storeList.size()];
storeList.getSelectedFlags(selected);
for (int i = 0; i < storeList.size();
i++) {
if (selected[i]) {
String item = store-
List.getString(i);
favoriteList.append(item, null);
storeList.delete(i);