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
Trusted Contributor
user17
Posts: 145
Registered: ‎01-23-2012
My Device: 9300

Display screen

[ Edited ]

Hi All,

 

          I want to display a screen first after i need to read xml and write to screen and display again; how it do these things. That is first i need to display background image in the screen then loading sympol(reading xml that time) after reading the values and images assign to background image screen. please help me how to do these....

 

 

 

Thanks in advance

Trusted Contributor
gopi
Posts: 126
Registered: ‎10-15-2010
My Device: Torch 9850

Re: Display screen

First Set the background image to vertical or horizontal manager so that it can be invalidated after reading xml.
After addding the fields to constructor,
add(Maincontent);
call a function using timertask it may wait upto few seconds so that user able to view the screen and then read xml upto that show the loading image by using runnable, after that set the background manager using new image and xml values to corresponding fields then invalidate the screen.

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

Re: Display screen

Where are these xml values coming from?

Trusted Contributor
user17
Posts: 145
Registered: ‎01-23-2012
My Device: 9300

Re: Display screen

Thanks to All,

 

             xml values are coming from server side and i need to display in my current screen, if i navigate to any other pages, again coming to same screen then it show old values agian read xml values then it write to same screen.

Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Display screen

use onExposed method of the screen. 

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Display screen

onExposed does not help here, at least not as far as I can see.  Remember that onExposed is called numerous times, like for example when a menu is displayed and then discarded.

 

From what I can see, the user must display a screen saying something like 'downloading', and then when the values come, must replace this with the actual data.  When that screen is revisited, the user must display the current data, while attempting to get new data, then update the screen with new data. 

 

The basic process is similar to that already described by gopi.  The screen will be recreated each time it is invoked, and if there is already downloaded data, it will be added and this is what the user will see.  The screen creation processing will start a download Thread, when the Thread completes it will save the downloaded data (for next time) and update the screen with the new data. 

 

Can the original poster please explain which parts of this process are causing problems.

 

Note that there are very many similar Threads already on the forum, that discuss downloading and displaying XML data.  The difference here is that the processing does not block while the data is being downloaded.  Instead the user can view old data (if any). 

Developer
kamal_nigam
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Display screen

Its  depend on the implementation how u want to used onExposed (with some flag and variable we can restricted to execute only when the screen pop from the stack. I also suggest instead of rendering entire screen again just replace your component with respect to xml data. 

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Display screen

"execute only when the screen pop from the stack"

 

Note that if you are looking to detect screen pop and push, you can use onUiEngineAttached().

 

"I also suggest instead of rendering entire screen again just replace your component with respect to xml data"

 

Be aware, that if you add, delete or replace a component, it will typically relayout the whole screen anyway. 

Trusted Contributor
user17
Posts: 145
Registered: ‎01-23-2012
My Device: 9300

Re: Display screen

 

Hi thanks to ALL for your valuable response, whatever pete_strange metioned in the above same thing iam looking.

 

        While downloading values from server, same time i need to show old data after completed the downloaded data i need to display new values. For that same object i need to assign new values, after i can call invalidate method.

This way it will work know?

 

 

Thanks in advance

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

Re: Display screen

Mostly, but I'd like to clarify a few things.  .

 

People have the impression that invalidate() updates the screen, so that it is needed to make sure things change.  If you are writing a standard UI Program this is not the case.  Most Fields will in fact cause a refresh themselves if you update them.  Sp for example, if you call:

<editField>.setText("New text");

there is no need for you to do an invalidate - the text on the screen will be updated automatically. 

 

In your case, once you have the downloaded values, you will do one of two things:

a) Update the Fields on the screen with new values - this is the option you have suggested.

b) Replace the Fields on the screen with updated Fields.

 

In fact,(b) will perform significantly faster than (a) provided you do the replace in one go.  So this is what i would recommend that you do.

 

The easiest way to do this is to have a Manager (say a VerticalFieldManager) on the screen, that has all the XML values.  Create a new VFM, add the updated XML Fields into that, then swap the old Manager for a the new one.

 

The one potentially downside of (b) is that the user, who is currently scrolling through the old data, will loose their position.  In fact I think that is a good thing, because it makes it clear that there is new data to see.