Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 71

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 70
71
3: Storing data
Code sample: Storing and viewing restaurant information
This code sample lets BlackBerry® device users save information about multiple restaurants and view information
about the most recently saved restaurant.
Example: Restaurants.java
/**
* Restaurants.java
* Copyright (C) 2004-2005 Research In Motion Limited.
*/
package com.rim.samples.docs.restaurants;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
import java.util.*;
import net.rim.device.api.i18n.*;
import net.rim.blackberry.api.invoke.*;
import net.rim.blackberry.api.browser.*;
import com.rim.samples.docs.resource.*;
public class Restaurants extends UiApplication implements RestaurantResource {
private AutoTextEditField namefield;
private AutoTextEditField addressfield;
private EditField phonefield;
private EditField websitefield;
private EditField specialtyfield;
private static Vector _data;
private static PersistentObject store;
private static ResourceBundle _resources;
private MenuItem saveItem = new MenuItem(_resources.getString(MENUITEM_SAVE), 110, 10)
{
Retrieve the most recently
saved object.
>Invoke _data.lastElement().
public void run() {
synchronized(store) {
_data = (Vector)store.getContents();
if (!_data.isEmpty()) {
RestaurantInfo info = (RestaurantInfo)_data.lastElement();
namefield.setText(info.getElement(RestaurantInfo.NAME));
addressfield.setText(info.getElement(RestaurantInfo.ADDRESS));
phonefield.setText(info.getElement(RestaurantInfo.PHONE));
specialtyfield.setText(info.getElement(
RestaurantInfo.SPECIALTY));}
}
}
Task Steps
Zobrazit stránku 70
1 2 ... 66 67 68 69 70 71 72 73 74 75 76 ... 285 286

Komentáře k této Příručce

Žádné komentáře