2011-12-19 38 views
1

ブラックベリーに問題があります。ブラックベリーのローディング画面の表示方法

読み込みダイアログをパーサーが完了するまで表示したいと思います。なぜなら、完成したタスクのXMLパーサーの後、私はそれを画面に表示するために使用する必要があるからです。

したがって、Parser XMLが完了するまで読み込みダイアログを表示するにはどうすればよいですか? 私を助けてください! ありがとうございます!!!!!!!!!!!!!!!!!

+0

こんにちは答え、次の...あなたが本当にあなたの受け入れ率を向上させる、その後答える必要がある場合は... –

+0

をしてください知っている事実 –

+0

あなたや私not.Let便利です、私のアプリケーションは、多くの時間がサーバーに接続していますそしてパーサXML ... 私はあなたの方法を試みたが、私はすべての場合を実装していない。 私は、アプリケーションを実行すると、私はpushScreenと私はgetArtistInforメソッドは、画面のコンストラクタで実行します。 私はあなたのソリューションを理解しましたが、私はすべてのケースで解決策が必要です! – Tama

答えて

2

。このリンク以下

アプリケーションのモミの中に小さなロジックを取る

次の.zipファイル画面をお待ちください http://supportforums.blackberry.com/t5/Java-Development/Sample-quot-Please-Wait-quot-screen-part-1/ta-p/493808 ダウンロードを実装する方法を説明しますリダイレクト、かなり簡単な作業で、すべての解析コンセプトを取りますスレッドに私たちの要求に応じて

は、たとえば、私は、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) 
    } 
    } 
+0

ご支援いただきありがとうございますが、「読み込み中...」を表示するにはどうすればいいですか?パーサープロセスが開始されたときのダイアログ – Tama

+0

i == list.getLength() - 1これが最後の要素であると仮定すると、pushingToNextScreen()という関数を呼び出してその画面を読み込んで新しい画面にプッシュすることができます –

0

Screenインスタンス(PopupScreen)をディスプレイスタックに配置してから、 'XML Parsing'モジュールの処理を開始し、完了するとその画面をディスプレイスタックから削除します。あなたのニーズを満たす、その画面上のいくつかのキープレスイベントを無効にする必要があるかもしれません。戻るボタンを押しても何もしない。そしてその画面にカスタマイズダイアログテキスト/アニメーションを追加します。

+0

Ok。しかし、プロセスのXML解析が完了したら、どうすればわかりますか? – Tama

+0

あなたの解析コードが別のスレッドで実行されていない場合、通常は解析コードモジュールの最後の行が実行された後、XML解析が行われます。最初に解析作業を正常に終了し、読み込み画面を追加しようとするとよいでしょう。 – Rupak

+0

XML解析が完了したら、「POPUP画面」をポップアップする必要があります。XMLパージとポップアップを開始する前に「ポップアップ画面」を押すことを意味します。 – alishaik786

関連する問題