Professional Documents
Culture Documents
Version: 6.0
Contents
1 Text fields...................................................................................................................................................................................... Label................................................................................................................................................................................................. Read-only text field........................................................................................................................................................................ Editable text field............................................................................................................................................................................ Password field................................................................................................................................................................................. Email address field.......................................................................................................................................................................... Search field...................................................................................................................................................................................... Autocomplete text field.................................................................................................................................................................. AutoText edit field........................................................................................................................................................................... Active AutoText edit field............................................................................................................................................................... 3 3 4 6 7 9 10 13 14 16 18 18 19 20 21 22 24 25 27 30 33 33 34 36 38 38 39 40 43 43 44
2 Choice fields................................................................................................................................................................................. Check box......................................................................................................................................................................................... Text-based drop-down list............................................................................................................................................................. Numeric drop-down list................................................................................................................................................................. Date field.......................................................................................................................................................................................... Date picker....................................................................................................................................................................................... File picker......................................................................................................................................................................................... Spin box............................................................................................................................................................................................ Location picker................................................................................................................................................................................ Tree field.......................................................................................................................................................................................... 3 Buttons.......................................................................................................................................................................................... Radio button.................................................................................................................................................................................... Toolbar.............................................................................................................................................................................................. Button............................................................................................................................................................................................... 4 Activity fields................................................................................................................................................................................ Gauge field...................................................................................................................................................................................... Activity indicator............................................................................................................................................................................. Progress indicator........................................................................................................................................................................... 5 Picture fields................................................................................................................................................................................. Bitmap field...................................................................................................................................................................................... Picture scroll field...........................................................................................................................................................................
6 Lists and tables............................................................................................................................................................................ Simple list......................................................................................................................................................................................... Rich list............................................................................................................................................................................................. Table................................................................................................................................................................................................. 7 Other components....................................................................................................................................................................... Browser field.................................................................................................................................................................................... Title bar............................................................................................................................................................................................ Map field.......................................................................................................................................................................................... 8 Provide feedback......................................................................................................................................................................... 9 Document revision history......................................................................................................................................................... 10 Legal notice..................................................................................................................................................................................
47 47 48 50 54 54 55 56 58 59 60
Text fields
Text fields
Label
Use a label to identify a UI component for a BlackBerry device user. Class Supported since Example LabelField BlackBerry Java SDK 4.0
public LabelFieldDemoScreen() { LabelField title = new LabelField("Label Field Demo", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); setTitle(title); LabelField labelField1 = new LabelField("Right-aligned label field", LabelField.FIELD_RIGHT); LabelField labelField2 = new LabelField("Centered label field", LabelField.FIELD_HCENTER | LabelField.FOCUSABLE); LabelField labelField3 = new LabelField("Left-aligned label field", LabelField.FIELD_LEFT); add(labelField1); add(labelField2); add(labelField3);
For more information about read-only text fields, see the UI Guidelines.
public class RichTextFieldDemo extends UiApplication { public static void main(String[] args) { RichTextFieldDemo theApp = new RichTextFieldDemo(); theApp.enterEventDispatcher(); } public RichTextFieldDemo() { pushScreen(new RichTextFieldDemoScreen()); }
class RichTextFieldDemoScreen extends MainScreen { Font myFont1, myFont2, myFont3; public RichTextFieldDemoScreen() { RichTextField title = new RichTextField("Read-only Text Field Demo"); setTitle(title); RichTextField rtf1 = new RichTextField("Right-aligned plain", RichTextField.TEXT_ALIGN_RIGHT); RichTextField rtf2 = new RichTextField("Centered extra bold", RichTextField.TEXT_ALIGN_HCENTER); RichTextField rtf3 = new RichTextField("Left-aligned italic", RichTextField.TEXT_ALIGN_LEFT); try {
FontFamily ff1 = FontFamily.forName("Times New Roman"); myFont1 = ff1.getFont(Font.PLAIN, 18); FontFamily ff2 = FontFamily.forName("Courier New"); myFont2 = ff2.getFont(Font.EXTRA_BOLD, 24); FontFamily ff3 = FontFamily.forName("Verdana"); myFont3 = ff3.getFont(Font.ITALIC, 24);
catch(final ClassNotFoundException cnfe) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("FontFamily.forName() threw " + cnfe.toString()); } }); } rtf1.setFont(myFont1); rtf2.setFont(myFont2); rtf3.setFont(myFont3); add(rtf1); add(rtf2); add(rtf3);
For more information about editable text fields, see the UI Guidelines.
Password field
import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.component.BasicEditField; public class BasicEditFieldDemo extends UiApplication { public static void main(String[] args) { BasicEditFieldDemo theApp = new BasicEditFieldDemo(); theApp.enterEventDispatcher(); } public BasicEditFieldDemo() { pushScreen(new BasicEditFieldDemoScreen()); }
class BasicEditFieldDemoScreen extends MainScreen { public BasicEditFieldDemoScreen() { setTitle("Editable Text Field Demo"); BasicEditField enterName = new BasicEditField("Your name: ", ""); BasicEditField enterPhone = new BasicEditField("Work number: ", "", 50, BasicEditField.FILTER_PHONE); add(enterName); add(enterPhone);
Password field
Use a password field when BlackBerry device users are required to type a password. You can apply filters to restrict the characters that users can type in the field. By default, the password field supports all characters. Class Supported since PasswordEditField BlackBerry Java SDK 4.2.1
Password field
Example
public class PasswordEditFieldDemo extends UiApplication { public static void main(String[] args) { PasswordEditFieldDemo theApp = new PasswordEditFieldDemo(); theApp.enterEventDispatcher(); } public PasswordEditFieldDemo() { pushScreen(new PasswordEditFieldDemoScreen()); }
class PasswordEditFieldDemoScreen extends MainScreen { public PasswordEditFieldDemoScreen() { setTitle("Password Field Demo"); BasicEditField enterUsername = new BasicEditField("Username: ", ""); PasswordEditField enterPIN = new PasswordEditField("PIN: ", "", 4, PasswordEditField.FILTER_NUMERIC); add(enterUsername);
add(enterPIN);
For more information about email address fields, see the UI Guidelines.
Search field
pushScreen(new EmailAddressEditFieldDemoScreen());
class EmailAddressEditFieldDemoScreen extends MainScreen { public EmailAddressEditFieldDemoScreen() { setTitle("Email Address Field Demo"); EmailAddressEditField enterEmail = new EmailAddressEditField("Email address: ", ""); add(enterEmail); } }
Search field
Use a search field to allow BlackBerry device users to filter a list of words that match the characters that they type in the field. Users can select one of the presented matches or continue typing to further restrict the available choices. When you create a search field, you must specify a source list. The source list supplies the strings to compare against, which can be hard-coded or derived from data sources on a BlackBerry device, such as contacts, memos, and tasks. Class Supported since Example KeywordFilterField BlackBerry Java SDK 4.5
10
Search field
public class SearchFieldDemo extends UiApplication { KeywordFilterField _keywordFilterField; CountryList _countryList; public static void main(String args[]) { SearchFieldDemo theApp = new SearchFieldDemo(); theApp.enterEventDispatcher(); } public SearchFieldDemo() { _countryList = new CountryList(); _countryList.addElement(new Country("Zimbabwe")); _countryList.addElement(new Country("Argentina")); _countryList.addElement(new Country("Brazil")); _countryList.addElement(new Country("Canada")); _countryList.addElement(new Country("Chile")); _countryList.addElement(new Country("China")); _countryList.addElement(new Country("Germany")); _keywordFilterField = new KeywordFilterField(); _keywordFilterField.setLabel(""); _keywordFilterField.setSourceList(_countryList, _countryList); SearchFieldDemoScreen screen = new SearchFieldDemoScreen(); screen.setTitle(_keywordFilterField.getKeywordField()); screen.add(_keywordFilterField); screen.addMenuItem(addElementItem); } pushScreen(screen);
void addElementToList(Country country) { _countryList.addElement(country); _keywordFilterField.updateList(); } private final MenuItem addElementItem = new MenuItem("Add country", 0, 0) { public void run() { _keywordFilterField.setKeyword("");
11
Search field
String[] selections = {"Add","Cancel"}; Dialog addDialog = new Dialog("Add Country", selections, null, 0, null); EditField inputField = new EditField("Country: ",""); addDialog.add(inputField); if(addDialog.doModal() == 0) { addElementToList(new Country(inputField.getText())); } }
};
class SearchFieldDemoScreen extends MainScreen { public SearchFieldDemoScreen(){}; } class CountryList extends SortedReadableList implements KeywordProvider { public CountryList() { super(new CountryListComparator()); } void addElement(Object element) { doAdd(element); } public String[] getKeywords(Object element) { if(element instanceof Country) { return StringUtilities.stringToWords(element.toString()); } return null; } final static class CountryListComparator implements Comparator { public int compare(Object o1, Object o2) { if (o1 == null || o2 == null) throw new IllegalArgumentException("Cannot compare null countries"); } return o1.toString().compareTo(o2.toString());
} }
12
class Country { private String _countryName; public Country(String countryName) { _countryName = countryName; } public String toString() { return _countryName; }
For more information about autocomplete text fields, see the UI & Navigation Development Guide.
13
public class AutoCompleteFieldApp extends UiApplication { public static void main(String[] args) { AutoCompleteFieldApp app = new AutoCompleteFieldApp(); app.enterEventDispatcher(); } AutoCompleteFieldApp() { pushScreen(new HomeScreen()); }
class HomeScreen extends MainScreen { public HomeScreen() { setTitle("Autocomplete Text Field Demo"); BasicFilteredList filterList = new BasicFilteredList(); String[] days = {"Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday","Sunday"}; filterList.addDataSet(1,days,"days",BasicFilteredList .COMPARISON_IGNORE_CASE); AutoCompleteField autoCompleteField = new AutoCompleteField(filterList); add(autoCompleteField); } }
14
Example
For more information about AutoText edit fields, see the UI Guidelines.
class AutoTextEditFieldDemoScreen extends MainScreen { public AutoTextEditFieldDemoScreen() { setTitle("AutoText Edit Field Demo"); AutoTextEditField myField = new AutoTextEditField("Description: ", ""); } add(myField);
15
For more information about active autocomplete text fields, see the UI Guidelines.
16
public ActiveAutoTextEditFieldDemoScreen() { setTitle("Active AutoText Edit Field Demo"); ActiveAutoTextEditField myField = new ActiveAutoTextEditField("Send a message to Mike: \n \n", ""); } add(myField);
17
Choice fields
Choice fields
Check box
Use check boxes for options that BlackBerry device users can select or clear. Users can select any number of check boxes in a group. Class Supported since Example CheckboxField BlackBerry Java SDK 3.7
public class CheckboxFieldDemo extends UiApplication { public static void main(String[] args) { CheckboxFieldDemo theApp = new CheckboxFieldDemo(); theApp.enterEventDispatcher(); } public CheckboxFieldDemo() { pushScreen(new CheckboxFieldDemoScreen()); }
18
} class CheckboxFieldDemoScreen extends MainScreen { public CheckboxFieldDemoScreen() { LabelField title = new LabelField("Check Box Demo", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH); setTitle(title); CheckboxField checkBox1 = new CheckboxField("Ignore Case", true); CheckboxField checkBox2 = new CheckboxField("Ignore Acronyms", false); add(checkBox1); add(checkBox2);
For more information about text-based drop-down lists, see the UI Guidelines.
19
public class TextDropdownListDemo extends UiApplication { public static void main(String[] args) { TextDropdownListDemo theApp = new TextDropdownListDemo(); theApp.enterEventDispatcher(); } public TextDropdownListDemo() { pushScreen(new TextDropdownListDemoScreen()); } } class TextDropdownListDemoScreen extends MainScreen { public TextDropdownListDemoScreen() { setTitle("Drop-down List Demo"); String choices[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Satu rday","Sunday"}; int iSetTo = 2; add(new ObjectChoiceField("Day of the week",choices,iSetTo)); } }
20
Date field
For more information about numeric drop-down lists, see the UI Guidelines.
} class NumericDropdownListDemoScreen extends MainScreen { public NumericDropdownListDemoScreen() { setTitle("Drop-down List Demo"); int iStartAt = 1; int iEndAt = 31; int iIncrement = 1; int iSetTo = 10; add(new NumericChoiceField("Day of the month",iStartAt,iEndAt,iIncrement,iSetTo-1)); } }
Date field
Use a date field to display the date and time. Class Supported since DateField BlackBerry Java SDK 3.6
21
Date picker
Example
Date picker
Use a date picker to permit BlackBerry device users to select a date and time.
22
Date picker
For more information about date and time pickers, see the UI Guidelines.
public class DatePickerDemo extends UiApplication { public static void main(String[] args) { DatePickerDemo theApp = new DatePickerDemo(); theApp.enterEventDispatcher(); } public DatePickerDemo() { pushScreen(new DatePickerDemoScreen()); }
class DatePickerDemoScreen extends MainScreen { public DatePickerDemoScreen() { setTitle("Date picker demo"); add(new RichTextField("Trying Date Picker"));
23
File picker
UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { DateTimePicker datePicker = DateTimePicker.createInstance(); datePicker.doModal(); } });
File picker
Use a file picker to permit BlackBerry device users to select a file from the BlackBerry device. Class Supported since Example FilePicker BlackBerry Java SDK 5.0
public class FilePickerDemo extends UiApplication { public static void main(String[] args) {
24
Spin box
class FilePickerDemoScreen extends MainScreen { public FilePickerDemoScreen() { setTitle("File Picker Demo"); add(new LabelField("Trying file picker")); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { FilePicker fp = FilePicker.getInstance(); FilePickListener fileListener = new FilePickListener(); fp.setListener(fileListener); fp.show(); } });
class FilePickListener implements FilePicker.Listener { public void selectionDone(String str) { Dialog.alert("You selected " + str); } }
Spin box
Use a spin box for items that BlackBerry device users can select from an ordered list. Class Supported since TextSpinBoxField BlackBerry Java SDK 5.0
25
Spin box
Example
public class SpinBoxDemo extends UiApplication { public static void main(String[] args) { SpinBoxDemo theApp = new SpinBoxDemo(); theApp.enterEventDispatcher(); } public SpinBoxDemo() { pushScreen(new SpinBoxDemoScreen()); }
class SpinBoxDemoScreen extends MainScreen { TextSpinBoxField spinBoxDays; TextSpinBoxField spinBoxMonths; SpinBoxFieldManager spinBoxMgr; public SpinBoxDemoScreen() { setTitle("Spin Box Demo"); final String[] DAYS = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}; final String[] MONTHS =
26
Location picker
{"January","February","March","April","May","June","July","August","September", "October","November","December"}; spinBoxMgr = new SpinBoxFieldManager(); spinBoxMgr.setVisibleRows(3); spinBoxDays = new TextSpinBoxField(DAYS); spinBoxMonths = new TextSpinBoxField(MONTHS); spinBoxMgr.add(spinBoxDays); spinBoxMgr.add(spinBoxMonths); add(spinBoxMgr);
public void close() { Dialog.alert("You selected " + (String)spinBoxDays.get(spinBoxDays.getSelectedIndex()) + " and " + (String)spinBoxMonths.get(spinBoxMonths.getSelectedIndex())); super.close(); }
Location picker
Use a location picker to permit BlackBerry device users to select a location from a list of options that you define. Class Supported since Example LocationPicker BlackBerry Java SDK 5.0
27
Location picker
public class LocationPickerApp extends UiApplication { public static void main(String[] args) { LocationPickerApp app = new LocationPickerApp(); app.enterEventDispatcher(); } public LocationPickerApp() { pushScreen(new LocationPickerAppScreen()); } static class LocationPickerAppScreen extends MainScreen implements LocationPicker.Listener, FieldChangeListener { private LocationPicker _locationPicker; private ButtonField _buttonField; private LabelField _nameLabel; private LabelField _descLabel; private LabelField _coordLabel; private boolean _mapsPresent = false; LocationPickerAppScreen() { setTitle("Location Picker Demo"); _buttonField = new ButtonField("Choose location", ButtonField.NEVER_DIRTY); _buttonField.setChangeListener(this); add(_buttonField); _nameLabel = new LabelField(); _descLabel = new LabelField(); _coordLabel = new LabelField(); add(_nameLabel); add(_descLabel); add(_coordLabel); Landmark[] landmarks = new Landmark[] {new Landmark("New York", "Times Square", new QualifiedCoordinates(40.757682, -73.98571, Float.NaN, Float.NaN, Float.NaN), null), new Landmark("New York","Central Park", new QualifiedCoordinates(40.783333, -73.966667, Float.NaN, Float.NaN, Float.NaN),
28
Location picker
null)}; int arraySize = 7; LocationPicker.Picker mapsLocationPicker = null; try { mapsLocationPicker = MapsLocationPicker.getInstance(); _mapsPresent = true; } catch(IllegalStateException ise) { arraySize--; } boolean gpsSupported = GPSInfo.getGPSDataSource() != null; if(!gpsSupported) { arraySize--; } LocationPicker.Picker[] locationPickersArray = new LocationPicker.Picker[arraySize]; locationPickersArray[--arraySize] = EnterLocationPicker.getInstance(false); locationPickersArray[--arraySize] = SuggestedLocationPicker.getInstance("App specific...", landmarks ); locationPickersArray[--arraySize] = RecentLocationPicker.getInstance(); locationPickersArray[--arraySize] = ContactsLocationPicker.getInstance(false); locationPickersArray[--arraySize] = GeotaggedPhotoPicker.getInstance(); if(_mapsPresent) { locationPickersArray[--arraySize] = mapsLocationPicker; } if(gpsSupported) { locationPickersArray[--arraySize] = GPSLocationPicker.getInstance(); } _locationPicker = LocationPicker.getInstance(locationPickersArray); Enumeration globalPickers = _locationPicker.getGlobalLocationPickers(); while (globalPickers.hasMoreElements()) { _locationPicker.addLocationPicker((LocationPicker .Picker)globalPickers.nextElement()); }
29
Tree field
_locationPicker.setListener(this);
public void locationPicked (LocationPicker.Picker picker, Landmark location) { if(location != null) { _nameLabel.setText("Location name: " + location.getName()); _descLabel.setText("Description: " + location.getDescription()); QualifiedCoordinates coordinates = location.getQualifiedCoordinates(); if(coordinates != null) { StringBuffer buff = new StringBuffer("Coordinates: "); double latitude = coordinates.getLatitude(); double longitude = coordinates.getLongitude(); buff.append("Latitude:"); buff.append(latitude); buff.append(", Longitude: "); buff.append(longitude); _coordLabel.setText(buff.toString()); } if(_mapsPresent) { Landmark[] landmark = {location}; MapsArguments mapsArgs = new MapsArguments(landmark); Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, mapsArgs); }
Tree field
Use a tree field to display components in a hierarchical structure. You can configure tree field nodes to be collapsible. Class TreeField
30
Tree field
class TreefieldDemoScreen extends MainScreen { public TreefieldDemoScreen() { setTitle("Tree Field Demo"); String String String String fieldOne = new String("Parent folder 1"); fieldTwo = new String("Parent folder 2"); fieldThree = new String("Sub-folder 1"); fieldFour = new String("Sub-folder 2");
31
Tree field
TreeField myTree = new TreeField(myCallback, Field.FOCUSABLE); int int int int node1 node2 node3 node4 = = = = myTree.addChildNode(0, fieldOne); myTree.addChildNode(0, fieldTwo); myTree.addChildNode(node2, fieldThree); myTree.addChildNode(node3, fieldFour);
myTree.setExpanded(node4, false); add(myTree); } private class TreeCallback implements TreeFieldCallback { public void drawTreeItem(TreeField _tree, Graphics g, int node, int y, int width, int indent) { String text = (String)_tree.getCookie(node); g.drawText(text, indent, y); } }
32
Buttons
Buttons
Radio button
Use radio buttons for options that BlackBerry device users can select from a set of choices. Users can select only one option in each set of radio buttons. Class Supported since Example RadioButtonGroup, RadioButtonField BlackBerry Java SDK 3.6
33
Toolbar
public RadioButtonDemoScreen() { setTitle("Radio Button Demo"); RadioButtonGroup rbg = new RadioButtonGroup(); add(new RadioButtonField("Option 1",rbg,true)); add(new RadioButtonField("Option 2",rbg,false)); }
Toolbar
Toolbars provide users with a quick and easy way to access frequent actions for an application or screen. Each toolbar consists of a set of icons that appears along the bottom of the screen. Only smartphones in the BlackBerry Storm Series and BlackBerry Torch 9800 smartphones use toolbars. Package Supported since Example Toolbar BlackBerry Java SDK 6.0
34
Toolbar
public class ToolbarDemo extends UiApplication { public static void main(String[] args) { ToolbarDemo theApp = new ToolbarDemo(); theApp.enterEventDispatcher();
public ToolbarDemo() { // Push a screen onto the UI stack for rendering. pushScreen(new ToolbarDemoScreen()); } private final static class ToolbarDemoScreen extends MainScreen { public ToolbarDemoScreen() { if (ToolbarManager.isToolbarSupported()) { setTitle("Toolbar Demo"); ToolbarManager manager = new ToolbarManager(); setToolbar(manager); try {
/* * To create more buttons, Repeat the following lines * up until manager.add() */ ToolbarButtonField button1 = new ToolbarButtonField(myImage, new StringProvider("butn1")); button1.setCommandContext(new Object() { public String toString() { return "Button1"; } }); button1.setCommand(new Command(new CommandHandler() { public void execute(ReadOnlyCommandMetadata metadata, Object { Dialog.alert("Executing command for " +
context)
context.toString());
35
Button
}));
} else { } }
Button
Use a button to allow BlackBerry device users to perform an action when they click the button. Class Supported since Example ButtonField BlackBerry Java SDK 4.0
For more information about buttons, see the UI Guidelines. For information about advanced buttons , read the knowledge base article at about how to implement advanced buttons, fields and managers .
36
Button
import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; public class ButtonFieldDemo extends UiApplication { public static void main(String[] args) { ButtonFieldDemo theApp = new ButtonFieldDemo(); theApp.enterEventDispatcher(); } public ButtonFieldDemo() { pushScreen(new ButtonFieldDemoScreen()); }
class ButtonFieldDemoScreen extends MainScreen { public ButtonFieldDemoScreen() { setTitle("Button Field Demo"); ButtonField addButton = new ButtonField("Add"); ButtonField delButton = new ButtonField("Delete"); add(addButton); add(delButton);
37
Activity fields
Activity fields
Gauge field
Use a gauge field to create a horizontal bar to display a progress indicator or a numeric value. Class Supported since Example GaugeField BlackBerry Java SDK 4.2
38
Activity indicator
public GaugeFieldDemoScreen () { setTitle("Gauge Field Demo"); GaugeField percentGauge = new GaugeField("Percent: ", 1, 100, 29, GaugeField.PERCENT); add(percentGauge);
Activity indicator
Use an activity indicator to display a visual cue that a task whose duration is unknown is progressing. If you can calculate how long the task will take, consider using a progress indicator instead. Class Supported since Example ActivityImageField BlackBerry Java SDK 6.0
public class ActivityIndicatorDemo extends UiApplication { public static void main(String[] args) { ActivityIndicatorDemo theApp = new ActivityIndicatorDemo();
39
Progress indicator
theApp.enterEventDispatcher();
class ActivityIndicatorDemoScreen extends MainScreen { ActivityIndicatorView view = new ActivityIndicatorView(Field.USE_ALL_WIDTH); ActivityIndicatorModel model = new ActivityIndicatorModel(); ActivityIndicatorController controller = new ActivityIndicatorController(); public ActivityIndicatorDemoScreen () { setTitle("Activity Indicator Demo"); view.setController(controller); view.setModel(model); controller.setModel(model); controller.setView(view); model.setController(controller); Bitmap bitmap = Bitmap.getBitmapResource("spinner.png"); view.createActivityImageField(bitmap, 5, Field.FIELD_HCENTER); } add(view);
Progress indicator
Use a progress indicator to display a visual cue that a task whose duration can be measured is progressing. If you cannot calculate how long the task will take, consider using an activity indicator instead. Class Supported since ProgressBarField BlackBerry Java SDK 6.0
40
Progress indicator
Example
class ProgressIndicatorDemoScreen extends MainScreen { ProgressIndicatorView view = new ProgressIndicatorView(0); ProgressIndicatorModel model = new ProgressIndicatorModel(0, 100, 0); ProgressIndicatorController controller = new ProgressIndicatorController(); ProgressThread _progressThread; public ProgressIndicatorDemoScreen() { setTitle("Progress Indicator Demo"); model.setController(controller); view.setModel(model);
41
Progress indicator
view.setController(controller); controller.setModel(model); controller.setView(view); view.setLabel("Percent completion"); view.createProgressBar(Field.FIELD_HCENTER); add(view); _progressThread = new ProgressThread(); _progressThread.start();
// A thread that simulates the processing of data class ProgressThread extends Thread { public void run() { for(int i = 0; i <= 100; ++i) { ProgressIndicatorDemoScreen.this.model.setValue(i); try { // Simulate work sleep(250); } catch(InterruptedException ie) { } } } }
42
Picture fields
Picture fields
Bitmap field
Use a bitmap field to display bitmap images that a BlackBerry device user can view. Class Supported since Example BitmapField BlackBerry Java SDK 3.7
For more information about bitmap fields, see the Multimedia Development Guide.
public class BitmapFieldDemo extends UiApplication { public static void main(String[] args) { BitmapFieldDemo theApp = new BitmapFieldDemo(); theApp.enterEventDispatcher(); } public BitmapFieldDemo() { pushScreen(new BitmapFieldDemoScreen()); }
43
class BitmapFieldDemoScreen extends MainScreen { public BitmapFieldDemoScreen () { setTitle("Bitmap Field Demo"); Bitmap bitmapImage = Bitmap.getBitmapResource("BlackBerry_Data_Stream.jpg"); BitmapField fieldDemo = new BitmapField(bitmapImage); add(fieldDemo); }
For more information about picture scroll fields, see the UI Guidelines.
public class PictureScrollFieldDemo extends UiApplication { public static void main(String[] args)
44
{ }
class PictureScrollFieldDemoScreen extends MainScreen { public PictureScrollFieldDemoScreen() { setTitle("Picture Scroll Field Demo"); Bitmap[] images = new Bitmap[3]; String[] labels = new String[3]; String[] tooltips = new String[3]; images[0] = Bitmap.getBitmapResource("image1.jpg"); labels[0] = "Label for image 1"; tooltips[0] = "Tooltip for image 1"; images[1] = Bitmap.getBitmapResource("image2.jpg"); labels[1] = "Label for image 2"; tooltips[1] = "Tooltip for image 2"; images[2] = Bitmap.getBitmapResource("image3.jpg"); labels[2] = "Label for image 2"; tooltips[2] = "Tooltip for image 2"; ScrollEntry[] entries = new ScrollEntry[3]; for (int i = 0; i < entries.length; i++) { entries[i] = new ScrollEntry(images[i], labels[i],tooltips[i]); } PictureScrollField pictureScrollField = new PictureScrollField(150, 100); pictureScrollField.setData(entries, 0); pictureScrollField.setHighlightStyle(HighlightStyle .ILLUMINATE_WITH_SHRINK_LENS); pictureScrollField.setHighlightBorderColor(Color.BLUE); pictureScrollField.setBackground(BackgroundFactory .createSolidTransparentBackground(Color.BLACK, 150)); pictureScrollField.setLabelsVisible(true);
45
add(pictureScrollField);
46
public class SimpleListDemo extends UiApplication { public static void main(String[] args) { SimpleListDemo theApp = new SimpleListDemo(); theApp.enterEventDispatcher(); } public SimpleListDemo() { pushScreen(new SimpleListScreen()); } private static final class SimpleListScreen extends MainScreen
47
Rich list
public SimpleListScreen() { super(Manager.NO_VERTICAL_SCROLL); setTitle("Simple List Demo"); add(new LabelField("My list", LabelField.FIELD_HCENTER)); add(new SeparatorField()); Manager mainManager = getMainManager(); SimpleList listField = new SimpleList(mainManager); listField.add("Item 1"); listField.add("Item 2"); listField.add("Item 3");
Rich list
Use a rich list to display a list of items that contain an optional image on the left, a list of labels beside the image and an optional description below the image and labels. Class Supported since Example RichList BlackBerry Java SDK 6.0
48
Rich list
public class RichListDemo extends UiApplication { public static void main(String[] args) { RichListDemo theApp = new RichListDemo(); theApp.enterEventDispatcher(); } public RichListDemo() { pushScreen(new RichListScreen()); } private static class RichListScreen extends MainScreen { public RichListScreen() { super(Manager.NO_VERTICAL_SCROLL); setTitle("Rich List Demo"); add(new LabelField("BlackBerry Devices", LabelField.FIELD_HCENTER)); add(new SeparatorField()); Manager mainManager = getMainManager(); RichList list = new RichList(mainManager, true, 2, 1); Bitmap bitmap1 = Bitmap.getBitmapResource("9500.png"); Bitmap bitmap2 = Bitmap.getBitmapResource("9000.png"); list.add(new 9500", "Description list.add(new 9000", "Description } Object[] {bitmap1, "Device 1", "BlackBerry Smartphone of Device 1."}); Object[] {bitmap2, "Device 2", "BlackBerry Smartphome of Device 2."});
49
Table
Table
Use a table model to store and display data in a table. Class Supported since Example TableModel BlackBerry Java SDK 6.0
For more information about tables, including sorted tables that group items under headers, see the UI Guidelines.
public class TableModelDemo extends UiApplication { public static void main(String[] args) { UiApplication app = new TableModelDemo(); app.enterEventDispatcher(); } public TableModelDemo() { pushScreen(new TableModelDemoScreen()); }
50
Table
private static final int NUM_ROWS = 4; private static final int NUM_COLUMNS = 3; private static final int IMAGE_WIDTH = 50; private String modelNum[] = {"8100", "8220", "8300", "8330", "8700g", "8800", "9000", "9500"}; private String modelName[] = {"Pearl", "Pearl Flip", "Curve", "Curve", "8700g", "8800", "Bold", "Storm"}; private String osVersion[] = {"4.3", "4.6", "4.5", "4.6", "4.1", "4.2.1", "4.6", "4.7"}; private String deviceYear[] = {"2006", "2008", "2008", "2008", "2005","2007", "2008", "2008"}; private String deviceInterface[] = {"keyboard/trackball", "keyboard/trackball", "keyboard/trackball", "keyboard/trackball", "keyboard", "keyboard/trackball", "keyboard/trackball", "keyboard/trackball/touch"}; public TableModelDemoScreen() { super(Manager.NO_VERTICAL_SCROLL); setTitle("Table Model Demo"); _style = new RegionStyles(BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1), Border.STYLE_SOLID), null, null, null, RegionStyles.ALIGN_LEFT, RegionStyles.ALIGN_MIDDLE); _tableModel = new TableModel(); _tableView = new TableView(_tableModel); _tableView.setDataTemplateFocus(BackgroundFactory .createLinearGradientBackground(Color.WHITE, Color.WHITE, Color.BLUEVIOLET, Color.BLUEVIOLET)); _controller = new TableController(_tableModel, _tableView); _tableView.setController(_controller); setStyle(); add(new LabelField("BlackBerry Devices", LabelField.FIELD_HCENTER)); add(new SeparatorField()); add(_tableView); for(int i = 0; i < modelName.length; i++) { String imageFileName = modelNum[i] + ".png";
51
Table
Bitmap bitmap = Bitmap.getBitmapResource(imageFileName); StringBuffer displayName = new StringBuffer(modelNum[i]); if(!modelName[i].equals(modelNum[i])) { displayName.append(" ("); displayName.append(modelName[i]); displayName.append(")"); } _tableModel.addRow(new Object[] {bitmap, displayName.toString(), osVersion[i], deviceYear[i], deviceInterface[i]}); } } public void setStyle() { DataTemplate dataTemplate = new DataTemplate(_tableView, NUM_ROWS, NUM_COLUMNS) { public Field[] getDataFields(int modelRowIndex) { Object[] data = (Object[]) _tableModel.getRow(modelRowIndex); Field[] fields = new Field[data.length]; for(int i = 0; i < data.length; i++) { if(data[i] instanceof Bitmap) { fields[i] = new BitmapField((Bitmap) data[i]); } else if(data[i] instanceof String) { fields[i] = new LabelField(data[i], Field.FOCUSABLE); } else { fields[i] = (Field) data[i]; } } } return fields;
};
dataTemplate.createRegion(new XYRect(0, 1, 1, 3), _style); dataTemplate.createRegion(new XYRect(0, 0, 2, 1), _style); dataTemplate.setRowProperties(0, new TemplateRowProperties(Font.getDefault().getHeight() + (_style.getBorder() == null ? 0 : _style.getBorder().getTop() +
52
Table
_style.getBorder().getBottom()) + (_style.getMargin() == null ? 0 : _style.getMargin().top + _style.getMargin().bottom))); for(int i = 1; i < NUM_ROWS; i++) { dataTemplate.createRegion(new XYRect(1, i, 1, 1), _style); dataTemplate.setRowProperties(i, new TemplateRowProperties(Font.getDefault().getHeight() + (_style.getBorder() == null ? 0 : _style.getBorder().getTop() + _style.getBorder().getBottom()) + (_style.getMargin() == null ? 0 : _style.getMargin().top + _style.getMargin().bottom))); } int width = IMAGE_WIDTH + (_style.getBorder() == null ? 0 : _style.getBorder().getTop() + _style.getBorder().getBottom()) + (_style.getMargin() == null ? 0 : _style.getMargin().top + _style.getMargin().bottom); dataTemplate.setColumnProperties(0, new TemplateColumnProperties(width)); dataTemplate.setColumnProperties(1, new TemplateColumnProperties(Display.getWidth() - width)); _tableView.setDataTemplate(dataTemplate); dataTemplate.useFixedHeight(true);
53
Other components
Other components
Browser field
Use a browser field to display web content in a BlackBerry device application. Class Supported since Example BrowserField BlackBerry Java SDK 5.0
For more information about browser fields, see the UI & Navigation Development Guide.
54
Title bar
public BrowserFieldDemoScreen() { BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig(); myBrowserFieldConfig.setProperty(BrowserFieldConfig .NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER); BrowserField browserField = new BrowserField(myBrowserFieldConfig); add(browserField); browserField.requestContent("http://www.blackberry.com");
Title bar
Use a title bar to provide BlackBerry device users with information at the top of your application. Most title bars contain only a title, but title bars can display the following items: application icon, descriptive title, and time application notifications, such as a new message indicator wireless connection indicators, including the wireless coverage level, network coverage, GPS indicator, Bluetooth indicator, and Wi-Fi connection indicator battery power indicator active call indicator Class Supported since Example StandardTitleBar BlackBerry Java SDK 6.0
55
Map field
import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; public class TitleBarDemo extends UiApplication { public static void main(String[] args) { TitleBarDemo theApp = new TitleBarDemo(); theApp.enterEventDispatcher(); } public TitleBarDemo() { pushScreen(new TitleBarDemoScreen()); } } class TitleBarDemoScreen extends MainScreen { public TitleBarDemoScreen() { StandardTitleBar myTitleBar = new StandardTitleBar() .addIcon("my_logo.png") .addTitle("Title Bar Demo") .addClock() .addNotifications() .addSignalIndicator(); myTitleBar.setPropertyValue(StandardTitleBar.PROPERTY_BATTERY_VISIBILITY, StandardTitleBar.BATTERY_VISIBLE_LOW_OR_CHARGING); setTitleBar(myTitleBar); } }
Map field
Use a map field to display a map in a BlackBerry device application. Class Supported since MapField BlackBerry Java SDK 6.0
56
Map field
Example
For more information about map fields and location-based services, see the Location-Based Services Development Guide.
public class MapFieldDemo extends UiApplication { public static void main(String[] args) { MapFieldDemo theApp = new MapFieldDemo(); theApp.enterEventDispatcher(); } public MapFieldDemo() { pushScreen(new MapScreen()); } } class MapScreen extends FullScreen { public MapScreen() { super( FullScreen.DEFAULT_CLOSE | FullScreen.DEFAULT_MENU ); MapField map = new MapField(); MapAction action = map.getAction(); action.setCentreAndZoom(new MapPoint(43.46518, -80.52237), 3); add(map); } }
57
Provide feedback
Provide feedback
To provide feedback on this deliverable, visit www.blackberry.com/docsfeedback.
58
24 August 2010
3 August 2010
Initial version.
59
Legal notice
Legal notice
10
2010 Research In Motion Limited. All rights reserved. BlackBerry, RIM, Research In Motion, and related trademarks, names, and logos are the property of Research In Motion Limited and are registered and/or used in the U.S. and countries around the world. Java is a trademark of Oracle America, Inc. Bluetooth is a trademark of Bluetooth SIG. Wi-Fi is a trademark of the Wi-Fi Alliance. All other trademarks are the property of their respective owners. This documentation including all documentation incorporated by reference herein such as documentation provided or made available at www.blackberry.com/go/docs is provided or made accessible "AS IS" and "AS AVAILABLE" and without condition, endorsement, guarantee, representation, or warranty of any kind by Research In Motion Limited and its affiliated companies ("RIM") and RIM assumes no responsibility for any typographical, technical, or other inaccuracies, errors, or omissions in this documentation. In order to protect RIM proprietary and confidential information and/or trade secrets, this documentation may describe some aspects of RIM technology in generalized terms. RIM reserves the right to periodically change information that is contained in this documentation; however, RIM makes no commitment to provide any such changes, updates, enhancements, or other additions to this documentation to you in a timely manner or at all. This documentation might contain references to third-party sources of information, hardware or software, products or services including components and content such as content protected by copyright and/or third-party web sites (collectively the "Third Party Products and Services"). RIM does not control, and is not responsible for, any Third Party Products and Services including, without limitation the content, accuracy, copyright compliance, compatibility, performance, trustworthiness, legality, decency, links, or any other aspect of Third Party Products and Services. The inclusion of a reference to Third Party Products and Services in this documentation does not imply endorsement by RIM of the Third Party Products and Services or the third party in any way. EXCEPT TO THE EXTENT SPECIFICALLY PROHIBITED BY APPLICABLE LAW IN YOUR JURISDICTION, ALL CONDITIONS, ENDORSEMENTS, GUARANTEES, REPRESENTATIONS, OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY CONDITIONS, ENDORSEMENTS, GUARANTEES, REPRESENTATIONS OR WARRANTIES OF DURABILITY, FITNESS FOR A PARTICULAR PURPOSE OR USE, MERCHANTABILITY, MERCHANTABLE QUALITY, NONINFRINGEMENT, SATISFACTORY QUALITY, OR TITLE, OR ARISING FROM A STATUTE OR CUSTOM OR A COURSE OF DEALING OR USAGE OF TRADE, OR RELATED TO THE DOCUMENTATION OR ITS USE, OR PERFORMANCE OR NON-PERFORMANCE OF ANY SOFTWARE, HARDWARE, SERVICE, OR ANY THIRD PARTY PRODUCTS AND SERVICES REFERENCED HEREIN, ARE HEREBY EXCLUDED. YOU MAY ALSO HAVE OTHER RIGHTS THAT VARY BY STATE OR PROVINCE. SOME JURISDICTIONS MAY NOT ALLOW THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES AND CONDITIONS. TO THE EXTENT PERMITTED BY LAW, ANY IMPLIED WARRANTIES OR CONDITIONS RELATING TO THE DOCUMENTATION TO THE EXTENT THEY CANNOT BE EXCLUDED AS SET OUT ABOVE, BUT CAN BE LIMITED, ARE HEREBY LIMITED TO NINETY (90) DAYS FROM THE DATE YOU FIRST ACQUIRED THE DOCUMENTATION OR THE ITEM THAT IS THE SUBJECT OF THE CLAIM. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW IN YOUR JURISDICTION, IN NO EVENT SHALL RIM BE LIABLE FOR ANY TYPE OF DAMAGES RELATED TO THIS DOCUMENTATION OR ITS USE, OR PERFORMANCE OR NONPERFORMANCE OF ANY SOFTWARE, HARDWARE, SERVICE, OR ANY THIRD PARTY PRODUCTS AND SERVICES REFERENCED HEREIN INCLUDING WITHOUT LIMITATION ANY OF THE FOLLOWING DAMAGES: DIRECT, CONSEQUENTIAL, EXEMPLARY, INCIDENTAL, INDIRECT, SPECIAL, PUNITIVE, OR AGGRAVATED DAMAGES, DAMAGES FOR LOSS OF PROFITS OR REVENUES, FAILURE TO REALIZE ANY EXPECTED SAVINGS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, LOSS OF
60
Legal notice
BUSINESS OPPORTUNITY, OR CORRUPTION OR LOSS OF DATA, FAILURES TO TRANSMIT OR RECEIVE ANY DATA, PROBLEMS ASSOCIATED WITH ANY APPLICATIONS USED IN CONJUNCTION WITH RIM PRODUCTS OR SERVICES, DOWNTIME COSTS, LOSS OF THE USE OF RIM PRODUCTS OR SERVICES OR ANY PORTION THEREOF OR OF ANY AIRTIME SERVICES, COST OF SUBSTITUTE GOODS, COSTS OF COVER, FACILITIES OR SERVICES, COST OF CAPITAL, OR OTHER SIMILAR PECUNIARY LOSSES, WHETHER OR NOT SUCH DAMAGES WERE FORESEEN OR UNFORESEEN, AND EVEN IF RIM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW IN YOUR JURISDICTION, RIM SHALL HAVE NO OTHER OBLIGATION, DUTY, OR LIABILITY WHATSOEVER IN CONTRACT, TORT, OR OTHERWISE TO YOU INCLUDING ANY LIABILITY FOR NEGLIGENCE OR STRICT LIABILITY. THE LIMITATIONS, EXCLUSIONS, AND DISCLAIMERS HEREIN SHALL APPLY: (A) IRRESPECTIVE OF THE NATURE OF THE CAUSE OF ACTION, DEMAND, OR ACTION BY YOU INCLUDING BUT NOT LIMITED TO BREACH OF CONTRACT, NEGLIGENCE, TORT, STRICT LIABILITY OR ANY OTHER LEGAL THEORY AND SHALL SURVIVE A FUNDAMENTAL BREACH OR BREACHES OR THE FAILURE OF THE ESSENTIAL PURPOSE OF THIS AGREEMENT OR OF ANY REMEDY CONTAINED HEREIN; AND (B) TO RIM AND ITS AFFILIATED COMPANIES, THEIR SUCCESSORS, ASSIGNS, AGENTS, SUPPLIERS (INCLUDING AIRTIME SERVICE PROVIDERS), AUTHORIZED RIM DISTRIBUTORS (ALSO INCLUDING AIRTIME SERVICE PROVIDERS) AND THEIR RESPECTIVE DIRECTORS, EMPLOYEES, AND INDEPENDENT CONTRACTORS. IN ADDITION TO THE LIMITATIONS AND EXCLUSIONS SET OUT ABOVE, IN NO EVENT SHALL ANY DIRECTOR, EMPLOYEE, AGENT, DISTRIBUTOR, SUPPLIER, INDEPENDENT CONTRACTOR OF RIM OR ANY AFFILIATES OF RIM HAVE ANY LIABILITY ARISING FROM OR RELATED TO THE DOCUMENTATION. Prior to subscribing for, installing, or using any Third Party Products and Services, it is your responsibility to ensure that your airtime service provider has agreed to support all of their features. Some airtime service providers might not offer Internet browsing functionality with a subscription to the BlackBerry Internet Service. Check with your service provider for availability, roaming arrangements, service plans and features. Installation or use of Third Party Products and Services with RIM's products and services may require one or more patent, trademark, copyright, or other licenses in order to avoid infringement or violation of third party rights. You are solely responsible for determining whether to use Third Party Products and Services and if any third party licenses are required to do so. If required you are responsible for acquiring them. You should not install or use Third Party Products and Services until all necessary licenses have been acquired. Any Third Party Products and Services that are provided with RIM's products and services are provided as a convenience to you and are provided "AS IS" with no express or implied conditions, endorsements, guarantees, representations, or warranties of any kind by RIM and RIM assumes no liability whatsoever, in relation thereto. Your use of Third Party Products and Services shall be governed by and subject to you agreeing to the terms of separate licenses and other agreements applicable thereto with third parties, except to the extent expressly covered by a license or other agreement with RIM. Certain features outlined in this documentation require a minimum version of BlackBerry Enterprise Server, BlackBerry Desktop Software, and/or BlackBerry Device Software. The terms of use of any RIM product or service are set out in a separate license or other agreement with RIM applicable thereto. NOTHING IN THIS DOCUMENTATION IS INTENDED TO SUPERSEDE ANY EXPRESS WRITTEN AGREEMENTS OR WARRANTIES PROVIDED BY RIM FOR PORTIONS OF ANY RIM PRODUCT OR SERVICE OTHER THAN THIS DOCUMENTATION.
61
Legal notice
Waterloo, ON N2L 3W8 Canada Research In Motion UK Limited Centrum House 36 Station Road Egham, Surrey TW20 9LF United Kingdom Published in Canada
62