11-25-2009 12:37 AM
I have run over some of the hundreds of posts on this subject, but I'm after a specific result and just need some direction.
My MainScreen calls a function which starts a thread, connects to a web server, retrieves data, and then displays in a RichTextField.
I would like to display a box exactly like Figure two in the following link.
http://docs.blackberry.com/en/developers/deliverab
I want to show this box just before I start the thread that connects to the web server. Then, I would like to get rid of the box just before the returned data (from web server) is sent to RichTextField.
Was RIM kind enough to give us an easy way to make this "Please Wait..." progress indicator?
If not, can someone give me some direction here to recreate? I'd like it to look exactly like that Please Wait indicator so as to keep the Blackberry "feel". I've read about Dialog and GuageField. Not quite clicking for me yet. Is that Please Wait shown in the above link just a GuageField? Or is it a screen or DialogFieldManager? I don't want to cover the entire screen with another screen, just want that popup exactly like in the link.
11-25-2009 12:47 AM
Implementing a callback mechanism where it tells you about the status of the thread connecting to web and using this information updtae your UI.
11-25-2009 12:51 AM
I kind of know when the network thread is done.
When my function that calls the network thread starts, that's when I would like to display the progress indicator. I have another function that is called from the network thread that receives the results and inserts them into a RichTextField. So, just before that RichTextField.setText() call, I would like to close the progress indicator.
The bigger question is more on creating a progress indicator that looks exactly like the second image in that link. The "Please wait.." screen.
11-25-2009 02:24 AM
i think this sample code will solve your problem
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManag
import net.rim.device.api.ui.*;
class FloatingScreenMain extends UiApplication {
private CustomPopupScreen _popup;
public static void main( String[] args ) {
FloatingScreenMain app = new FloatingScreenMain();
app.enterEventDispatcher();
}
FloatingScreenMain() {
_popup = new CustomPopupScreen(this);
UiApplication.getUiApplication().invokeLater( new Runnable() {
public void run() {
MyScreen screen = new MyScreen();
pushScreen (screen);
pushScreen ( _popup );
}
});
}
public void closeScreen()
{
UiApplication.getUiApplication().invokeLater( new Runnable() {
public void run() {
popScreen ( _popup );
}
});
}
}
class MyScreen extends MainScreen{
public MyScreen()
{
super();
}
protected void paint (Graphics g)
{
super.paint (g);
g.setColor(Color.ROYALBLUE);
g.fillRect( 0, 0, Display.getWidth(), Display.getHeight());
}
}
class CustomPopupScreen extends Screen {
private final static int _CUSTOM_WIDTH = 250;
private final static int _CUSTOM_HEIGHT = 60;
private final static int _Y = ( Display.getHeight() - _CUSTOM_HEIGHT ) / 2;
private FloatingScreenMain _parent;
CustomPopupScreen (FloatingScreenMain parent) {
super (new VerticalFieldManager (Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR));
_parent = parent;
}
protected void sublayout( int width, int height ) {
setExtent( _CUSTOM_WIDTH, _CUSTOM_HEIGHT );
setPosition( 25, _Y );
layoutDelegate( _CUSTOM_WIDTH, _CUSTOM_HEIGHT );
}
public int getPreferredWidth()
{
return _CUSTOM_WIDTH;
}
public int getPreferredHeight()
{
return _CUSTOM_HEIGHT;
}
protected void paintBackground( Graphics g ) {
g.setColor( Color.BLACK );
g.fillRect( 0, 0, getPreferredWidth(), getPreferredHeight());
g.setColor( Color.WHITE );
g.drawBitmap(10, 15, 31, 29, Bitmap.getBitmapResource("image.png"), 0, 0);
g.drawText("Please wait...", 50, 20);
}
protected boolean touchEvent (TouchEvent message)
{
switch (message.getEvent() )
{
case TouchEvent.CLICK:
_parent.closeScreen();
return true;
}
return false;
}
}
11-25-2009 02:50 AM
zany,
This looks like it coud be what I need. I'm having a problem calling this class though. I created a new class, then copy and pasted this code.
I typically would do the following:
FloatingScreenMain fsmScreen = new FloatingScreenMain();
UiApplication.getUiApplication().pushScreen(fsmScr
But this gives me an error on the .pushScreen saying cannot find symbol. I'm assuming this is because FloatingScreenMain extends UiApplication.
Do you know how I can call this?
Thank you very much for the code!
11-25-2009 02:56 AM
nevermind. It's pretty late here and I didn't read the code close enough. The constructor that extends MainScreen is actually called MyScreen instead of FloatingScreenMain.
I'll have to tweak this code, but you definitely got a great start for me. Thank you again!