Android应用程序崩溃java.lang.IllegalArgumentException:视图未附加到窗口管理器

时间:2013-04-19 07:41:35

标签: android android-webview

开发了一个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();
            }
        }

0 个答案:

没有答案