如何在黑莓中显示加载屏幕

发布于 2024-12-21 18:14:49 字数 735 浏览 0 评论 0原文

我的黑莓手机有问题。

        // Stream connection
        streamConnection = (StreamConnection) Connector
                .open(_url);
        // Document Builder Factory
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
                .newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        docBuilder.isValidating();
        // Parsing inputStream
        doc = docBuilder.parse(streamConnection.openInputStream());
        doc.getDocumentElement().normalize();
        NodeList list = doc.getElementsByTagName("*");

我想显示加载对话框,直到上面的任务解析器完成。因为在完成任务 XML 解析器之后,我必须使用它在屏幕上显示。

那么,如何显示加载对话框直到解析器 XML 完成? 请帮我 ! 非常感谢你!!!!!!!!!!!!!!!

I have a problem with Blackberry.

        // Stream connection
        streamConnection = (StreamConnection) Connector
                .open(_url);
        // Document Builder Factory
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
                .newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        docBuilder.isValidating();
        // Parsing inputStream
        doc = docBuilder.parse(streamConnection.openInputStream());
        doc.getDocumentElement().normalize();
        NodeList list = doc.getElementsByTagName("*");

I want to display Loading Dialog until above the task parser is complete. Because after finished task XML parser, i have to use it for display on screen.

So, how to display Loading dialog until Parser XML is complete?
Please help me !
Thanks you very much!!!!!!!!!!!!!!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

策马西风 2024-12-28 18:14:49

您好,这是非常简单的任务,

以下链接将重定向您如何实施请等待屏幕
http ://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/ta-p/493808
下载该 .zip 文件

接下来将小逻辑放入您的应用程序中,首先将所有解析概念放入 Thread 中,

例如我正在使用 xml 解析器演示,我将根据我们的要求进行转换,

private class Connection extends Thread{
        Vector nodes_vect=new Vector();
        Vector elements_vect=new Vector();
        public Connection(){
            super();
        }

        public void run(){
            // define variables later used for parsing
            Document doc;
            StreamConnection conn;

            try{
                //providing the location of the XML file,
                //your address might be different
                conn=(StreamConnection)Connector.open
                  ("http://localhost:8000/content/test.xml;deviceside=true");//  http://localhost:8000/content/test.xml
                //next few lines creates variables to open a
                //stream, parse it, collect XML data and
                //extract the data which is required.
                //In this case they are elements,
                //node and the values of an element
                DocumentBuilderFactory docBuilderFactory
                  = DocumentBuilderFactory. newInstance(); 
                DocumentBuilder docBuilder
                  = docBuilderFactory.newDocumentBuilder();
                docBuilder.isValidating();
                doc = docBuilder.parse(conn.openInputStream());
                doc.getDocumentElement ().normalize ();
                NodeList list=doc.getElementsByTagName("*");
                _node=new String();
                _element = new String();
                //this "for" loop is used to parse through the
                //XML document and extract all elements and their
                //value, so they can be displayed on the device

                for (int i=0;i<list.getLength();i++){
                    Node value=list.item(i).
                      getChildNodes().item(0);
                    _node=list.item(i).getNodeName();
                    _element=value.getNodeValue();
                  nodes_vect.addElement(_node);
                  elements_vect.addElement(_element);
                   if(i==list.getLength()-1){


                       pushingToNextScreen(nodes_vect, elements_vect);//after last element it will 
                   }
                }//end for
            }//end try
            //will catch any exception thrown by the XML parser
            catch (Exception e){
                System.out.println(e.toString());
            }
        }//end connection function
    }// end connection class
}//end XML_Parsing_Sample

您可以从任何地方调用它在哪里

import java.util.Vector;

import javax.microedition.io.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

class XML_Parsing_Sample extends UiApplication{
    //creating a member variable for the MainScreen
    MainScreen _screen= new MainScreen();
    //string variables to store the values of the XML document
    String _node,_element;
    Connection _connectionthread;

    public static void main(String arg[]){
        XML_Parsing_Sample application = new XML_Parsing_Sample();
        //create a new instance of the application
        //and start the application on the event thread
        application.enterEventDispatcher();
    }

    public XML_Parsing_Sample() {

        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new LoadingScreen());
            }
        });


       // pushScreen(_screen); // creating a screen
        //creating a connection thread to run in the background
        _connectionthread = new Connection();
        _connectionthread.start();//starting the thread operation
    }

    public void pushingToNextScreen(final Vector node,final Vector elem){
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                 UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
                 UiApplication.getUiApplication().pushScreen(new datascreen(node, elem));//after last element it will call mainscreen constructer
            }
        });
    }

  class datascreen extends MainScreen
  {
      public datascreen(Vector node,Vector elem) {
        //you can write your logic and design with data(vectors contain all data)
    }
  }

hi this is pretty much easy task

following link redirect you how to implement Please wait screen
http://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/ta-p/493808
download that .zip file

Next take small logic into your application firs take all your parsing concept into a Thread

for example i am taking xml parser demo and i will convert according to our requirement

private class Connection extends Thread{
        Vector nodes_vect=new Vector();
        Vector elements_vect=new Vector();
        public Connection(){
            super();
        }

        public void run(){
            // define variables later used for parsing
            Document doc;
            StreamConnection conn;

            try{
                //providing the location of the XML file,
                //your address might be different
                conn=(StreamConnection)Connector.open
                  ("http://localhost:8000/content/test.xml;deviceside=true");//  http://localhost:8000/content/test.xml
                //next few lines creates variables to open a
                //stream, parse it, collect XML data and
                //extract the data which is required.
                //In this case they are elements,
                //node and the values of an element
                DocumentBuilderFactory docBuilderFactory
                  = DocumentBuilderFactory. newInstance(); 
                DocumentBuilder docBuilder
                  = docBuilderFactory.newDocumentBuilder();
                docBuilder.isValidating();
                doc = docBuilder.parse(conn.openInputStream());
                doc.getDocumentElement ().normalize ();
                NodeList list=doc.getElementsByTagName("*");
                _node=new String();
                _element = new String();
                //this "for" loop is used to parse through the
                //XML document and extract all elements and their
                //value, so they can be displayed on the device

                for (int i=0;i<list.getLength();i++){
                    Node value=list.item(i).
                      getChildNodes().item(0);
                    _node=list.item(i).getNodeName();
                    _element=value.getNodeValue();
                  nodes_vect.addElement(_node);
                  elements_vect.addElement(_element);
                   if(i==list.getLength()-1){


                       pushingToNextScreen(nodes_vect, elements_vect);//after last element it will 
                   }
                }//end for
            }//end try
            //will catch any exception thrown by the XML parser
            catch (Exception e){
                System.out.println(e.toString());
            }
        }//end connection function
    }// end connection class
}//end XML_Parsing_Sample

you can call this from any where

import java.util.Vector;

import javax.microedition.io.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

class XML_Parsing_Sample extends UiApplication{
    //creating a member variable for the MainScreen
    MainScreen _screen= new MainScreen();
    //string variables to store the values of the XML document
    String _node,_element;
    Connection _connectionthread;

    public static void main(String arg[]){
        XML_Parsing_Sample application = new XML_Parsing_Sample();
        //create a new instance of the application
        //and start the application on the event thread
        application.enterEventDispatcher();
    }

    public XML_Parsing_Sample() {

        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                UiApplication.getUiApplication().pushScreen(new LoadingScreen());
            }
        });


       // pushScreen(_screen); // creating a screen
        //creating a connection thread to run in the background
        _connectionthread = new Connection();
        _connectionthread.start();//starting the thread operation
    }

    public void pushingToNextScreen(final Vector node,final Vector elem){
        UiApplication.getUiApplication().invokeLater(new Runnable() {
            public void run() {
                 UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
                 UiApplication.getUiApplication().pushScreen(new datascreen(node, elem));//after last element it will call mainscreen constructer
            }
        });
    }

  class datascreen extends MainScreen
  {
      public datascreen(Vector node,Vector elem) {
        //you can write your logic and design with data(vectors contain all data)
    }
  }
红衣飘飘貌似仙 2024-12-28 18:14:49

在开始处理“XML 解析”模块之前,将 Screen 实例 (PopupScreen) 放在显示堆栈上,并在完成后从显示堆栈中删除该屏幕。您可能需要覆盖该屏幕上的某些按键事件以满足您的需要,例如按下后退按钮时不执行任何操作。并在该屏幕上添加您的自定义对话框文本/动画。

Put a Screen instance (PopupScreen) on the display stack before start processing 'XML Parsing' module, and upon completion remove that screen from display stack. You may need to override some key press event on that screen that satisfy your need, e.g. do nothing on back button press. And add your customize dialog text / animation on that screen.

倾城花音 2024-12-28 18:14:49

在下面的链接中找到应用程序 (PleaseWait.zip) 以显示请稍候。

http://supportforums.blackberry .com/t5/Java-Development/problem-in-gaugfield-show-urgent/td-p/964925

find the application (PleaseWait.zip) in below link to show the please wait.

http://supportforums.blackberry.com/t5/Java-Development/problem-in-gaugfield-show-urgent/td-p/964925

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文