// Add an ActivityIndicatorView with label and animation centered in a
// horizontal layout
bitmap = Bitmap.getBitmapResource("spinner.png");
_views[1] =
ActivityIndicatorFactory.createActivityIndicator(
new HorizontalFieldManager(), Field.FIELD_HCENTER,
bitmap, 5, 0, "horizontal centered layout",
Field.FIELD_HCENTER);
add(_views[1]);
add(new SeparatorField());
// Add a centered ActivityIndicatorView between two focusable fields
add(new LabelField("focusable field", Field.FOCUSABLE));
bitmap = Bitmap.getBitmapResource("spinner2.png");
_views[2] =
ActivityIndicatorFactory.createActivityIndicator(
Field.FIELD_HCENTER, bitmap, 6, Field.FIELD_HCENTER,
"centered between focusable fields",
Field.FIELD_HCENTER);
add(_views[2]);
add(new LabelField("focusable field", Field.FOCUSABLE));
add(new SeparatorField());
// Add a right justified ActivityIndicatorView
bitmap = Bitmap.getBitmapResource("spinner.png");
_views[3] =
ActivityIndicatorFactory.createActivityIndicator(
Field.USE_ALL_WIDTH, bitmap, 5, Field.FIELD_RIGHT,
"right justified layout", Field.FIELD_VCENTER);
add(_views[3]);
add(new SeparatorField());
Background background; // Reuse this reference
// Add an ActivityIndicatorView featuring a solid black background
bitmap = Bitmap.getBitmapResource("orchid.png");
background = BackgroundFactory.createSolidBackground(Color.BLACK);
_views[4] =
ActivityIndicatorFactory.createActivityIndicator(0, bitmap, 6,
0);
_views[4].setBackground(background);
add(_views[4]);
add(new LabelField("solid background"));
add(new SeparatorField());
// Add an ActivityIndicatorView to another ActivityIndicatorView
bitmap = Bitmap.getBitmapResource("progress.png");
background = BackgroundFactory.createSolidBackground(Color.DARKGRAY);
_views[5] =
ActivityIndicatorFactory.createActivityIndicator(0, bitmap, 12,
0, "view added to another", 0);
_views[5].setBackground(background);
bitmap = Bitmap.getBitmapResource("spinner.png");
_views[6] =
ActivityIndicatorFactory.createActivityIndicator(0, bitmap, 5,
0);
_views[5].add(_views[6]);
add(_views[5]);
final MenuItem cancelItem =
new MenuItem(new StringProvider("Cancel spinners "), 0x230020,
0);
cancelItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
for (int i = _views.length - 1; i >= 0; --i) {
_views[i].getModel().cancel();
}
}
}));
final MenuItem resetItem =
new MenuItem(new StringProvider("Reset spinners "), 0x230030, 0);
resetItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
for (int i = _views.length - 1; i >= 0; --i) {
_views[i].getModel().reset();
}
}
}));
final MenuItem resumeItem =
new MenuItem(new StringProvider("Resume spinners "), 0x230040,
0);
resumeItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
for (int i = _views.length - 1; i >= 0; --i) {
_views[i].getModel().resume();
}
}
}));
final MenuItem delayedStop =
new MenuItem(new StringProvider("Delayed start"), 0x230050, 0);
delayedStop.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
for (int i = _views.length - 1; i >= 0; --i) {
final DelayedStart ds = new DelayedStart(_views[i]);
ds.start();
}
}
}));
final MenuItem delayedStart =
new MenuItem(new StringProvider("Delayed stop"), 0x230060, 0);
delayedStart.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
for (int i = _views.length - 1; i >= 0; --i) {
final DelayedStop ds = new DelayedStop(_views[i]);
ds.start();
}
}
}));
final MenuItem showPopupItem =
new MenuItem(new StringProvider("Show Popup"), 0x230010, 0);
showPopupItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
Bitmap bitmap = Bitmap.getBitmapResource("orchid2.png");
final ActivityIndicatorView view =
ActivityIndicatorFactory.createActivityIndicator(0,
bitmap, 6, Field.FIELD_HCENTER);
bitmap = Bitmap.getBitmapResource("progress2.png");
final ActivityIndicatorView view2 =
ActivityIndicatorFactory.createActivityIndicator(
new HorizontalFieldManager(),
Field.FIELD_HCENTER, bitmap, 6, 0,
"horizontal", Field.FIELD_HCENTER);
final ActivityPopupScreen activityPopupScreen =
new ActivityPopupScreen(view);