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: 248
Registered: ‎11-23-2009
My Device: Not Specified

LabelField on MainScreen is not getting updated

Hi All,

 

This a pretty annoying issue which i am unable to resolve.

 

I have a labelField on the MainScreen of my App. Now when i want to go from my mainscreen to another screen within my app, the labelField should show a message to the user.

for eg: "Processing Request....please wait"

 

I am using the LabelField.setText("") method to update the text of the labelField.

Surprisingly this update is not showing. So i figured that maybe i need to refresh the screen. So i tried Screen.Invalidate(). Yet no success..

 

Can someone tell me how this issue can be resolved?

 

Thanks,

Saket

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: LabelField on MainScreen is not getting updated

never had any issues with that. how about posting the offending code segment (set text and display new screen)?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: LabelField on MainScreen is not getting updated

did u checked whether ur screen gets repainted or not

 

try to debug or giv code

 

i never faced such issue

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: LabelField on MainScreen is not getting updated

Okay

 

below is the method which should ideally update the labelField & call the next screen

 

public void DispScreen2()
{
    try
    {  

            lblStatus.setText("Loading Screen2.....please wait");
            //UiApplication.getUiApplication().repaint();
            //this.invalidate();
            MyApplication.thisapp.invokeLater(new Runnable()
            {
                public void run()
                {
                    //Create instance of class Screen2
                    Screen2 screen=new Screen2();
                    //Display Screen
                    UiApplication.getUiApplication().pushScreen(screen); 
                }
            });          
    }
    catch(Exception ex)
    {}
}

 

 

Thanks,

Saket

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: LabelField on MainScreen is not getting updated

why do you use invokelater? when you use setText you have to be on the event thread already. if you are not, you have to include setText in the invokelater.

iirc setText invalidates a textfield.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: LabelField on MainScreen is not getting updated

Thanks for your suggestion Simon

 

i use invokelater because i wanted all the actions related to my current screen (read update labelField) to be performed first before i start calling the next screen.

 

i tried removing the invokeLater but it didnt help, the labelField isnt getting updated on the screen.

i also tried putting the setText method in the invokeLater but then too no success.

 

btw, could please explain:

 

when you use setText you have to be on the event thread already. if you are not, you have to include setText in the invokelater.

 

"event thread"?

 

iirc setText invalidates a textfield.

 

"iirc"?

 

Thanks,

Saket

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: LabelField on MainScreen is not getting updated

hi any solutions please?

 

Thanks,

Saket

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: LabelField on MainScreen is not getting updated

i think the label field must be updating but since u immediatly move to next screen u r unable to view it.

 

inside ur try catch block just keep

this code label.settext("plz wait");

 

and remove all code related to pushing of screen

 

try this just to check that now does the label gets repainted or not?

 

Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified

Re: LabelField on MainScreen is not getting updated

yes if i remove the call to the next screen the label is updated and i can see it.

 

That is also the reason why i used invokelater for calling the next screen.

 

 

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: LabelField on MainScreen is not getting updated

invokelater is usually executed immediately.

you could use a timertask or something, but on the other hand, why let the user wait when it is ready at the moment?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter