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: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator
Accepted Solution

DialogFieldManager Popup Text change dynamically

I am currently displaying a popup msg using DialogFieldManager with text "Please Wait.."

 

But instead of it I need to change the text dynamically according to the background process like "connecting.." , "logging in.." etc..

 

When I tried to accompalish that by changing the text and invalidate the popup screen , it does not reflect in the screen..

 

How to achieve my requirement? Please help

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: DialogFieldManager Popup Text change dynamically

Can you post the related code?

 

E.

Developer
Posts: 543
Registered: ‎12-23-2010
My Device: Z10
My Carrier: Airtel

Re: DialogFieldManager Popup Text change dynamically

Hi Sheelu,

 

ensure that you are updating and invalidating by holding event lock or not.

 

try like this,

 

synchronized (UiApplication.getEventLock())
                    {
                        dialogfieldmanager.setMessage(new RichTextField(message));
                        invalidate();
                    }

 

Thanks.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: DialogFieldManager Popup Text change dynamically

Thanks for replying..

 

Here is the code for displaying the popup msg

 

DialogFieldManager manager = new DialogFieldManager();
popUpMsg = new LabelField("Connecting...");
manager.addCustomField(popUpMsg);
Screen popup = new PopupScreen(manager);
UiApplication.getUiApplication().pushScreen(popup);
.
.
.
.
.
.

synchronized (UiApplication.getEventLock()) {

															popUpMsg.setText("logging in..");
									manager.invalidate();
									popup.invalidate();
								}

 Where am i making mistake??

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: DialogFieldManager Popup Text change dynamically

Try:

 

popup.invalidate() or updateLayout().

 

E.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: DialogFieldManager Popup Text change dynamically

I tried both.. But there is still no change :-(

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 543
Registered: ‎12-23-2010
My Device: Z10
My Carrier: Airtel

Re: DialogFieldManager Popup Text change dynamically

Hi,

 

Try this sample,

 

public class MyPoPup extends PopupScreen{

    private DialogFieldManager dfm;
    private Timer _timer;
    private LabelField popUpMsg;
    boolean isRun = true;
    public MyPoPup() {
        super(new VerticalFieldManager());
        dfm = new DialogFieldManager(FIELD_HCENTER);
        popUpMsg = new LabelField("Connecting...");
        dfm.addCustomField(popUpMsg);
        dfm.setIcon(new BitmapField(Bitmap.getPredefinedBitmap(Bitmap.HOURGLASS)));
        
        add(dfm);
    }
    protected void onDisplay()
    {
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            
            public void run() {
                _timer = new Timer();
                _timer.schedule(new MyTask(), 0);
                
            }
        });
    }

    private class MyTask extends TimerTask
    {
        int i = 0;
        int k=0;
        String message[] = {"Starting...","Checking...","Verifying...","Logging...","Success...","Welcome Pradeep"};
        public void run() {
            
            while(isRun)
            {
                i++;
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if(i%3 == 0)
                {
                    k++;
                    if(k>5)k=0;
                    synchronized (UiApplication.getEventLock())
                    {
                        popUpMsg.setText(message[k]);
                        invalidate();
                    }
                    
                }
            }
        }
        
    }
}

 

Thanks.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: DialogFieldManager Popup Text change dynamically

Thank you so much Pradeep.

 

When I tried your code by pushing the Popup screen directly in the the class that extends the UIApplication , it works fine..

 

But when I use another parentscreen to push this application then it does not show any popup..

 

 

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Developer
Posts: 543
Registered: ‎12-23-2010
My Device: Z10
My Carrier: Airtel

Re: DialogFieldManager Popup Text change dynamically

 

It should run.

Can you post your parent screen code how u r pushing?

 

Thanks.

Developer
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: DialogFieldManager Popup Text change dynamically

I use the following code..

 

UiApplication.getUiApplication().pushScreen(new MyPopUp());

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.