0

开发的 Android 应用程序包括 Webview 以及进度条和对方向更改的支持,但我的应用程序崩溃生成以下错误:

java.lang.IllegalArgumentException:视图未附加到窗口管理器

这是我的代码:-

protected ProgressDialog mSpinner;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            mSpinner = new ProgressDialog(this);
            mSpinner.setMessage("Loading..Please Wait!");
            setContentView(R.layout.activity_main);
                    WebView myWebView = (WebView) findViewById(R.id.webview);
                    myWebView.loadUrl("http://www.google.com");}
            @Override
        public void onConfigurationChanged(Configuration newConfig){
            super.onConfigurationChanged(newConfig);
        }
    public class MyCustomWebViewClient extends WebViewClient {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                            view.loadUrl(url);
               return true;
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
               // Log.d("mytag","Page Loading Started"); 
                mSpinner.show();
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);

                    if ( mSpinner.isShowing()) {
                         mSpinner.dismiss();
             //Log.d("mytag","Page Loading finished");
                //mSpinner.dismiss();
            }
        }
4

0 回答 0