Infinite Progress bar with loading message

1,001 views
Skip to first unread message

Vinay Gurram

unread,
Mar 29, 2013, 3:04:52 AM3/29/13
to codenameone...@googlegroups.com
Hi, 
I want to add an Infinite Progress bar  with simple text "loading ...." to the form. How do I achieve this?


Chen Fishbein

unread,
Mar 29, 2013, 3:38:11 AM3/29/13
to codenameone...@googlegroups.com
Create a Container add a Label and the Infinite Progress bar

Vinay Gurram

unread,
Mar 29, 2013, 5:00:12 AM3/29/13
to codenameone...@googlegroups.com
Where do I place this container? 
I show Infinite Progress bar when transition occurs from page 1 to page 2.
My Code is like this ::

public static ConnectionRequest myNetwork(URI myUrl,final ResponseObject myresponse) {
 
String URL = myUrl.toASCIIString();
 
ConnectionRequest request = new ConnectionRequest(){
 
protected void readResponse(InputStream input) throws IOException {
 myresponse
.resp(JsonParser.parse(new InputStreamReader(input)));
 
}
 
 
protected void postResponse(){
 
Display.getInstance().getCurrent().refreshTheme();
 
 
}
 
};
 request
.setHttpMethod("GET");
 request
.setUrl(URL);
 
InfiniteProgress ip = new InfiniteProgress();
 
Dialog dlg = ip.showInifiniteBlocking();
 request
.setDisposeOnCompletion(dlg);
 
NetworkManager.getInstance().addToQueueAndWait(request);
 
System.out.println(URL);
 
return request;
 
}

and I use this myNetwork  to make connection requests to dynamically load next page.

Chen Fishbein

unread,
Mar 29, 2013, 6:44:47 AM3/29/13
to codenameone...@googlegroups.com
Try this:

        InfiniteProgress ip = new InfiniteProgress();
        
        Dialog d = new Dialog();
        d.setDialogUIID("Container");
        d.setLayout(new BorderLayout());
        Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        cnt.addComponent(new Label("Loading..."));
        cnt.addComponent(ip);
        d.addComponent(BorderLayout.CENTER, cnt);
        d.setTransitionInAnimator(CommonTransitions.createEmpty());
        d.setTransitionOutAnimator(CommonTransitions.createEmpty());
        d.showPacked(BorderLayout.CENTER, false);
 
    request.setDisposeOnCompletion(d);

Vinay Gurram

unread,
Mar 29, 2013, 7:36:34 AM3/29/13
to codenameone...@googlegroups.com
I tried it but I have not noticed any change.  Code worked as previously. 
I added infiniteImage constant to theme-constants. It has a animation.gif attached to it. Do I have to remove that?

Chen Fishbein

unread,
Mar 29, 2013, 9:28:34 AM3/29/13
to codenameone...@googlegroups.com
no need to give animated gif we are rotating the image in code, so it could be png or jpg.
No idea how the code I gave you didn't change a thing notice I added this line

 cnt.addComponent(new Label("Loading..."));

Vinay Gurram

unread,
Apr 4, 2013, 8:10:56 AM4/4/13
to codenameone...@googlegroups.com
I made a new native theme. I was trying to use the infinteProgress function. I placed the connectionRequest in beforeMain() function.
There is no progress bar and just white blank page. 
So, I added  ajaxLoader.jpg to infiniteImage   themeConstant in the theme. It did not solve my problem either. 

Vinay Gurram

unread,
Apr 4, 2013, 8:44:39 AM4/4/13
to codenameone...@googlegroups.com
Sorry my mistake. I added thread.sleep(5000) to the code to see the InfiniteProgress bar. After removing it and more connection requests, now I can see infiniteProgress Bar. 
Reply all
Reply to author
Forward
0 new messages