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
Regular Contributor
Posts: 61
Registered: ‎02-24-2010
My Device: Storm 2
My Carrier: AT&T

help in refreshing the screen

Hi..

 

I am getting some problem with refreshing the screen..

What i am doing is i am generating some checkboxefield instances dynamically depending upon the no. of items in the list. for example if i have 5 items in list then 5 checkboxes are created. This is working very fine. by using the managers screen is showing the checkboxes and listfield items. when i go to another screen to add some items to the list i want on coming back to the original screen when i reload the list, number of instances of the checkboxfield should be increased by the no. of items added and screen should display the new no. of checkboxes and new items of the listfield. 

 

Items are being displayed but the new checkboxes are not created.

 

Is there any way to refresh the screen so that when i come back to the screen, the no. of fields on the screen must be changed according to the situation. 

 

I hope i am able to explain my problem...Please suggest some solution. 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: help in refreshing the screen

Override onFocus() of the original screen that contains the checkboxes, and call invalidate() .

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: help in refreshing the screen

I prefer overriding onExposed than onFocus to refresh the screen.  I think both get called in a lot of circumstances where the screen does not need to be refreshed so I would minimize the processing in there if the screen dos not need to be refreshed. 

 

Alternatively, and I think in this case better, use a modal invocation of your lower level screen, and then in the processing one return from the screen, you can refresh the current screen.  For example:

 

UiApplication.getUiApplication().pushModalScreen(new lower level screen that adds items);

refreshCurrentList();

Developer
Posts: 94
Registered: ‎10-01-2009
My Device: Not Specified

Re: help in refreshing the screen

I'm never sure when to use invalidate() and when to use something else.  I was messing about with TextBoxFields for another thread and found that if I changed the size of the TextBoxField then calling invalidate() did not force a refresh but calling the MainScreen's updateLayout() did.  I usually prefer subtlety to the bigger hammer.  Is there a good reference explaining all this?

Regular Contributor
Posts: 61
Registered: ‎02-24-2010
My Device: Storm 2
My Carrier: AT&T

Re: help in refreshing the screen

Thanx for replying.. But how can i refresh the screen while staying at the same screen.. e.g. i have some checkboxes on the screen and i want on pressing remove in menu the checkboxes marked as set must be removed from the screen and screen should be refreshed so that it doesn't show the deleted checkboxes anymore. I am not going to any other screen. I have only one screen and want to refresh that screen only.

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: help in refreshing the screen

If you remove a Field, the Manager should refresh the Sceen for you.  Give it a try and watch what happemns.

 

With regard to invalidate() verses updateLayout, the way i think about it, invalidate causes a repaint, so no Fields will change in size.  If you need to change the layout, then invalidate() will not do it for you.