変換

2011-07-10 1 views
2

私はかなりうまく機能しているの進歩のためのthisのチュートリアルを使用して、私は糸車に変換したいのですが、このようachiveする方法があり、 enter image description here変換

should i have to go for 


    ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "", 
          "Loading. Please wait...", true) 

私は、そのためのコードをあなたのように更新されましたが、

public class Webview extends Activity { 

    WebView mWebView; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 

     // Adds Progrss bar Support 
     this.getWindow().requestFeature(Window.FEATURE_PROGRESS); 
     setContentView(R.layout.weblayout); 

     // Makes Progress bar Visible 
     getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 

     // Get Web view 
     mWebView = (WebView) findViewById(R.id.MyWebview); //This is the id you gave 
                  //to the WebView in the main.xml 
     mWebView.getSettings().setJavaScriptEnabled(true); 
     mWebView.getSettings().setSupportZoom(true);   //Zoom Control on web (You don't need this 
                  //if ROM supports Multi-Touch  
     mWebView.getSettings().setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM 

     // Load URL 
     mWebView.loadUrl("http://www.firstdroid.com/advertisement.htm"); 


     // Sets the Chrome Client, and defines the onProgressChanged 
     // This makes the Progress bar be updated. 
     final Activity MyActivity = this; 
     mWebView.setWebChromeClient(new WebChromeClient() { 
     public void onProgressChanged(WebView view, int progress) 
     { 


      ProgressDialog dialog = new ProgressDialog(MyActivity); 
      dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
      dialog.setMessage("Loading. Please wait..."); 
      dialog.setIndeterminate(true); 

      MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded 

      // Return the app name after finish loading 
      if(progress == 100) 
       MyActivity.setTitle(R.string.app_name); 
      } 
     }); 



    }//End of Method onCreate 
} 
+0

一つは、あなたは何このhttp://www.chrisdanielson.com/2010/05/04/android-webview-and-the-indeterminant-progress-solution/ – user667340

+0

することにより、この問題を解決することができますMyActivity.setProgress()メソッド?進捗状況は0〜100の範囲の整数なので、間違ったパラメータで呼び出すと思います。また、私はそのような目的のための静的メソッドの使用は受け入れられないと思う。 – kord

答えて

2

糸車(STYLE_SPINNERとして知られている)が動作していないそのインスタンス化するときProgressDialogのデフォルトの実装であります書かれたうまく動作する必要があります。

通常、ProgressDialogのスタイルを設定するには、ProgressDialogsetProgressStyleメソッドをshowメソッドを呼び出す前に呼び出すことができます。これと同じように:

ProgressDialog dialog = new ProgressDialog(this); 
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
dialog.setMessage("Loading. Please wait..."); 
dialog.setIndeterminate(true); 
+0

ありがとうございました。心配してくれてありがとうございました。私は上記の行を置き換えなければならないコードの行を指摘できますか?もう一度ありがとう – user667340

+1

更新された質問を見てください、私は置いてみましたが、動作していない、それについて私を案内してください – user667340