First of all, we create an ActivityIndicatorView. This is an implementation of AbstractProgressIndicatorView and is used for representing progress where the duration is not known. When you don't know how long the tasks will take, this is the recommended view.
You can use the typical Windows style hourglass, a spinner or any other image you want. You can customize your own animation. So as we said before, you just need to create a new image created by all the images joined horizontally, each one being a frame of the animation.
ActivityIndicatorView myview = new ActivityIndicatorView(Field.USE_ALL_WIDTH);
A model ActivityIndicatorModel and a controller ActivityIndicatorController are available and they represent implementations of AbstractProgressIndicatorModel and AbstractProgressIndicatorController respectively. These represent the progress when the duration is not known. If the controller we set does not consume an input event, then the delegate will process the input.
ActivityIndicatorModel mymodel = new ActivityIndicatorModel();
ActivityIndicatorController mycontroller = new ActivityIndicatorController();
public ActivityIndicatorDemoScreen ()
setTitle("Activity Indicator Demo");
Now we associate each controller and model with the view; the model and the view with the controller; and the controller with the model. Please note that there’s no need to associate any view to the model.
We create a bitmap with the image we want to use as an activity indicator. You could be as creative as you want but remember that the user is waiting for some task and maybe is not as happy as you with the “creation".
Bitmap mybitmap = Bitmap.getBitmapResource("mycustomanimation.png");
Last, we create the ActivityImageField through the createActivityImageField of the view object. This creates an ActivityImageField and adds it to this view. The bitmap provided must be a series of frames laid out horizontally, each with equal width. The total width of the bitmap will be the width of an individual frame multiplied by the total number of frames.
myview.createActivityImageField(bitmap, 5, Field.FIELD_HCENTER);
That’s all. As a final tip, please use a descriptive text (for example, "Loading..." or "Reading..."). If an action is very long and you want to communicate what is happening at each stage, provide text that explains what is happening (for example, "Deleting..." or "Installing...").