Code sample
class BetterExample {
private int fieldsCount;
private Field _fieldWithFocus;
private boolean _validLayout;
private boolean _validLayout;
}
Importing individual classes
A BlackBerry® Java Application that uses only a small number of classes from a package should only import the individual classes.
Code sample
import net.rim.blackberry.api.browser.Browser;
Multilanguage support
The BlackBerry® Integrated Development Environment includes a resource mechanism for creating string resources. The
Localization API is part of the
net.rim.device.api.i18n
package. MIDP applications do not support localization.
TheBlackBerry Integrated Development Environment stores resources for a locale in a
ResourceBundle
object. A
ResourceBundleFamily
object contains a collection of
ResourceBundles
, which groups the resources for an
application. The application can switch languages, depending on the locale of the BlackBerry device user, without requiring new
resource bundles.
You can use the BlackBerry Integrated Development Environment to compile each resource bundle into a separately compiled .cod
file. You can load the appropriate .cod files onto BlackBerry devices with the other .cod files for the application.
Resources are organized in a hierarchy based on inheritance. If a string is not defined in a locale, a string from the next closest
locale is used.
Best practice: Storing text strings in resource files
Instead of using text in source code, design applications to use resource files for localization (adapt to specific languages and
regions).
Consider the following guidelines:
•
Store the text strings for each locale in a single resource file.
•
In your source code, use unique identifiers to make use of the appropriate resource files.
•
Design the application to dynamically retrieve the appropriate resource file to display to the BlackBerry® device user based
on the locale of the BlackBerry device user.
Fundamentals Guide
Multilanguage support
20