Localization sample app
The localization sample application demonstrates how you can create an application that manages multiple regions and languages using separate resource files instead of hard-coding textual elements into your source code.
In the sample application, there is an object choice field that allows the user to select a country. When a BlackBerry device user selects the country, the resource file for the appropriate locale is accessed and displayed.
This file defines the LocalizationDemo class , the LocalizationDemoScreen class, and the InfoScreen class.
The LocalizationDemo class extends the UiApplication class, and contains the following constructor and methods:
The LocalizationDemoScreen class extends the MainScreen class, and implements the LocalizationDemoResource and FieldChangeListener interfaces. It contains the following constructor and methods:
The InfoScreen class extends MainScreen, implements LocalizationDemoResource and displays the information for the currently selected locale.
This sample features the following classes:
This class manages resource files to provide functionality that supports the internationalization of applications. The ResourceBundle class contains location-specific objects that you can load from the resource bundle that matches a BlackBerry device user's locale.
The sample application creates a UI that allows you to showcase the ResourceBundle class by selecting a specific location and then access relevant location information that is stored in the resource files.
Install the sample app
In the BlackBerry Java Development Environment, open the workspace that you want to add the sample application to.
In the Files pane, right-click < workspace_name >.
Click Add project to < workspace_name >.
In the Add project to < workspace_name > dialog box, browse to the localizationdemo folder. The default location of this folder is C:\Program Files\Research In Motion\BlackBerry JDE 5.0.0\samples\com\rim\samples\device\ui\localizationdemo.
Click the LocalizationDemo.jdp file.
The sample is also available in github.
Run the sample app
In the BlackBerry Java Development Environment, in the workspace that you added the LocalizationDemo project to, right-click LocalizationDemo.
Click Build project.
On the taskbar, click Start > Applications > Research In Motion > BlackBerry JDE 5.0.0 > Device Simulator.
On the Home screen of the BlackBerry Smartphone Simulator click All.
Click the Localization Demo icon.