Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel
Accepted Solution

using gaugefield

 

hii , i use a class extend gaugefield but i can't set this gauge field in all screen whidth, how can i do it?

Developer
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: using gaugefield

GaugeField g=new GaugeField("", 0, 100, 100, USE_ALL_WIDTH);
add(g);
Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: using gaugefield

i use a custom class extends GaugeField and i setExtent(DIsplay.getWidth(),height) but does not work
Developer
Posts: 216
Registered: ‎02-18-2010
My Device: 9350,8520
My Carrier: no

Re: using gaugefield

import net.rim.device.api.ui.component.GaugeField;

public class CustomGuageField extends GaugeField
{
	public CustomGuageField(String label,int min,int max , int start)
	{
		super(label,min,max,start,USE_ALL_WIDTH);
	}
}

 you can create custom guage field by calling the super class.

Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: using gaugefield

i tested it, but it doesn't work
Highlighted
Trusted Contributor
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: using gaugefield

hi ,

i give other class for guage field, use it

 

 

********processdemo.java*********************

 

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

 
 class processdemo extends Thread 
 {
   private int maximum, timeout;
   private boolean useful;
   private PopupScreen popup;
   private GaugeField gaugeField;
    
   public processdemo(String title, int maximum, int timeout)
   {
        super();
        this.maximum = maximum;
        this.timeout = timeout;

        DialogFieldManager manager = new DialogFieldManager();

        popup = new PopupScreen(manager);
        gaugeField = new GaugeField(null, 1, maximum, 1, GaugeField.NO_TEXT);

        manager.addCustomField(new LabelField(title));
        manager.addCustomField(gaugeField);
  }


  public void run()
  {
    useful = true;
   
  
    UiApplication.getUiApplication().invokeLater(new Runnable()
    {
        public void run()
        {
            UiApplication.getUiApplication().pushScreen(popup);
        }
    });
    int iterations = 0;
    while (useful)
    {
        try
        {
            Thread.sleep(timeout);
        }
        catch (Exception e)
        {}
        if (++iterations > maximum)
            iterations = 1;

        gaugeField.setValue(iterations);
    }

    if (popup.isDisplayed())
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                UiApplication.getUiApplication().popScreen(popup);
            }
        });
    }
   }

public  void remove()
{
   useful=false;
}  

 }

 

********************************************

****for call use below code*******************

 


                Thread threadToRun = new Thread()
                {     
                    public void run()
                    {
                        UiApplication.getUiApplication().invokeLater(new Runnable()
                        {
                            public void run()
                            {
                                       demo=new processdemo("Loading",50,550);
                                       demo.start();          
                            }
                        });
                                try
                                {      
                                    //back ground process
                                      
                                }
                                catch (Throwable t)
                                {
                                    t.printStackTrace();
                                    throw new RuntimeException("Exception detected while waiting: " + t.toString());
                                }
                               
                                 UiApplication.getUiApplication().invokeLater(new Runnable()
                                 {
                                    public void run()
                                    {
                                        System.out.println("come back");
                                        demo.remove();
                                    }
                                   
                                });
                            }
                      };   
                        threadToRun.start();

 

i hope above code help u.

Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: using gaugefield

thanks but how to stop the progress bar using this code while finish
Trusted Contributor
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: using gaugefield

 

when ur background process will finish,

 

demo.remove()  stop the guagefield.

Developer
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: using gaugefield

it 's work thanksSmiley Happy
Trusted Contributor
Posts: 159
Registered: ‎02-17-2011
My Device: Not Specified

Re: using gaugefield

ur welcome.

 

Feel free to press  kudo if u got ur solution