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 ProgressBarField
Supported since BlackBerry® Java® SDK 6.0
Example This screen shows a progress indicator.

For more information about progress indicators, see the UI Guidelines.

Code sample: Creating a progress indicator

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.progressindicator.*;

public class ProgressIndicatorDemo extends UiApplication
{
     public static void main(String[] args)
    {
         ProgressIndicatorDemo theApp = new ProgressIndicatorDemo(); 
         theApp.enterEventDispatcher(); 
    }
     
     public ProgressIndicatorDemo() 
     { 
         pushScreen(new ProgressIndicatorDemoScreen()); 
     } 
}

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);
        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)
                {                    
                }                
            }           
        }
    }   
}
Next topic: Picture fields
Previous topic: Activity indicator

Was this information helpful? Send us your comments.