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

  • 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 240
241
16: Localizing applications
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.i18n.*;
import com.rim.samples.docs.resource.*;
/* This sample demonstrates how to store text strings in separate resource
files for specific locales rather than providing text strings directly
in the code. In your source code, you retrieve the string from the resource
to display the appropriate text for the user locale. */
public class CountryInfo extends UiApplication {
public static void main(String[] args) {
CountryInfo theApp = new CountryInfo();
theApp.enterEventDispatcher();
}
public CountryInfo() {
pushScreen(new HelloWorldScreen());
}
}
final class HelloWorldScreen extends MainScreen implements CountryInfoResource {
private InfoScreen _infoScreen;
private ObjectChoiceField choiceField;
private int select;
private static ResourceBundle _resources = ResourceBundle.getBundle(
CountryInfoResource.BUNDLE_ID, CountryInfoResource.BUNDLE_NAME);
public HelloWorldScreen() {
super();
LabelField title = new LabelField(_resources.getString(APPLICATION_TITLE),
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField(_resources.getString(FIELD_TITLE)));
String choices[] = _resources.getStringArray(FIELD_COUNTRIES);
choiceField = new ObjectChoiceField(
_resources.getString(FIELD_CHOICE), choices);
add(choiceField);
}
public boolean onClose() {
Dialog.alert(_resources.getString(CLOSE));
System.exit(0);
return true;
}
private MenuItem _viewItem = new MenuItem(_resources, MENUITEM_VIEW, 110, 10) {
public void run() {
select = choiceField.getSelectedIndex();
_infoScreen = new InfoScreen();
UiApplication.getUiApplication().pushScreen(_infoScreen);
}
};
private MenuItem _closeItem = new MenuItem(_resources, MENUITEM_CLOSE,
200000, 10) {
public void run() {
Zobrazit stránku 240
1 2 ... 236 237 238 239 240 241 242 243 244 245 246 ... 285 286

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

Žádné komentáře