开发者

Show loading form while parsing XML in J2ME

I am parsing xml from remote server using kxml parser. I am using the following code to parse xml

public void validateUser(String name, String password, String mobile, String code) 
{
    Display.getDisplay(parent).setCurrent(new LoadingBarCanvas(parent));
    ReadXML xmlThread = new ReadXML();
    xmlThread.start();
    int count = 0;
    URL = "http://www.acb.info/mobapp/Web_service/checkLogin.php?mobile=" + mobile + "&userId=dbz&password=123&code=" + code + "&output=xml";
    while (xmlThread.isAlive()) 
    {
        if (count == 0) 
        {
            System.out.println("thread is alive");
        }
        count++;
    }

    StringBuffer sb = new StringBuffer();
    System.out.println("bookVector " + bookVector.size());
    for (int i = 0; i < bookVector.size(); i++) {
        ChapterClass book = (ChapterClass) bookVector.elementAt(i);
        sb.append("\n");
        sb.append("Name : ");
        sb.append(book.getName());
        status = book.getName();
        sb.append("\n");
        sb.append("Descrition : ");
        sb.append(book.getDescription());
        smcID = book.getDescription();
        userName.setString(book.getRating());
                //=book.getRating();
        sb.append("\n");

    }
    System.out.println(sb.toString());


开发者_如何学C    if (status.equalsIgnoreCase("Sucess..")) 
    {

        StoreData("smcid",smcID);
        StoreData("userid",userName.getString());

        showInputLogInSuccessfull();
    } 
    else 
    {
        showInputLogInFailed();
    }
}

I want to show loading Form from another class while xml is parsing. I have tried Display.getDisplay(parent).setCurrent(new LoadingBarCanvas(parent)); to display loading form but it don't show the loading Form. So how can I solve this problem ?


you can use the GIF file for loading screen

Here you can find the sample code

if u r using the Netbeans then Go to library->Add Netbeans MIDP compaonent

U'll get the class of netbeans.splachscreen,netbeans.waitingsceen Which u can use and integrate in ur code

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜