将进度条转换为纺车

时间:2011-07-10 16:52:14

标签: android

我正在使用this教程进行相当好的进展,我想将它转换为旋转轮是否有任何方法可以实现这样的效果, 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
}

1 个答案:

答案 0 :(得分:2)

在实例化时,旋转轮(称为STYLE_SPINNER)是ProgressDialog的默认实现,因此您编写的代码应该可以正常工作。

要通常设置ProgressDialog的样式,您可以在调用setProgressStyle方法之前调用您创建的ProgressDialog上的show方法。像这样:

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