BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-24-2009, 01:51 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: 8800
PIN: N/A
Carrier: simulator
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete LabelField in VerticalFieldManager

Please Login to Remove!

Hi guys, need your help here...

I've created LabelField inside verticalfieldmanager, the code:

PHP Code:
cox = new VerticalFieldManager(Manager.VERTICAL_SCROLL Manager.VERTICAL_SCROLLBAR);
labelLoading = new LabelField("Please wait..." ,DrawStyle.ELLIPSIS LabelField.USE_ALL_WIDTH LabelField.FOCUSABLE LabelField.HCENTER);
cox.add(labelLoading);
add(cox); 
at another public void, i try to delete the labeLoading, the code:

PHP Code:
public void setStatusOff() {
       
statusField.setText("Done");
       
delete(labelLoading);
    } 
but i always got error...
Offline  
Old 04-24-2009, 02:48 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
cox.delete(labelLoading);
__________________
Blessed is the end user who expects nothing, for he/she will not be disappointed. (Franklin's Rule)
Offline  
Old 04-24-2009, 10:41 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: 8800
PIN: N/A
Carrier: simulator
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Ivanov, thx

still not working....
Offline  
Old 04-24-2009, 10:48 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

is it not working at all, or are you getting an exception?

you need to check the field is diplayed before deleting it:

if(labelLoading.isVisible()){
cox.delete(labelLoading);
}
Offline  
Old 04-24-2009, 11:23 AM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Unless cox is out of scope. You could try:
Code:
public void setStatusOff() {
       statusField.setText("Done");
       labelLoading.getManager().delete(labelLoading);
    }
You may also need to ensure that you are executing on the event thread.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 04-24-2009, 02:10 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

My guess is that your setStatusOff() code is being called from a listener thread, not the UI thread. If that is the case, you will need to wrap your setText() in a Runnable and place it in the event queue by calling invokeLater().
Offline  
Old 04-24-2009, 05:53 PM   #7 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Or you can synchronize on Application.getEventLock():

Code:
public void setStatusOff() {
       statusField.setText("Done");
       synchronized(Application.getEventLock()) {
           labelLoading.getManager().delete(labelLoading);
       }
    }
which is generally more efficient.

Which is what I meant.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 04-25-2009, 06:40 PM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: 8800
PIN: N/A
Carrier: simulator
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx Doug, your guesses is absolutely right...

and i 've tried to use the code from hrbuckley, and it's working smoooooth...

Thx to you all...
Offline  
Old 04-25-2009, 09:10 PM   #9 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

You are most welcome.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 04-26-2009, 04:48 AM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: 8800
PIN: N/A
Carrier: simulator
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Aother question:

How can i add field in "public void setStatusOff() {..." ?
Offline  
Old 04-26-2009, 07:35 PM   #11 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

As long as you do it on the event thread, either the synchronized portion in my example, or the run() method of the Runnable in Dougsg38p's suggestion you should be fine, adding it in the normal way.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 04-30-2009, 12:41 AM   #12 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2008
Model: 8800
PIN: N/A
Carrier: simulator
Posts: 21
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thx for the help, guys...

it means alot to me to working on the project.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.