开发者

conversion of progress bar to spinning wheel

开发者 https://www.devze.com 2023-03-19 18:02 出处:网络
i am using this tutorial for progress which is working pretty well , i want to convert it to the spinning wheel is there any way to achive like this ,

i am using this tutorial for progress which is working pretty well , i want to convert it to the spinning wheel is there any way to achive like this ,

conversion of progress bar to spinning wheel

should i have to go for 


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

I have updated like this but its not working

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_V开发者_如何学运维ISIBILITY_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
}


The spinning wheel (known as the STYLE_SPINNER) is the default implementation of a ProgressDialog when instantiated, therefore the code you have written should work fine.

To usually set the style of the ProgressDialog, you can call the setProgressStyle method on the ProgressDialog you create before calling the show method. Like so:

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

精彩评论

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