进度对话框不能停止 [英] progress dialog could not stop

查看:143
本文介绍了进度对话框不能停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来android.I正在使用进度对话框,在我的应用程序,但它不能stop.In我的应用程序,我使用webview.In第一次活动我有连接button.In第二个活动连接到Facebook,code是available.In次活动code:

 公共无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.facebook);
    wvFacebook.setWebViewClient(新MyWebViewClient());
    wvFacebook.loadUrl(strFacebook);
}私有类MyWebViewClient扩展WebViewClient
{
    公共布尔shouldOverrideUrlLoading(的WebView视图,字符串URL)
    {
        view.getSettings()setJavaScriptEnabled(真)。
        view.loadUrl(URL);
        返回true;
    }    @覆盖
    公共无效onPageStarted(的WebView视图,字符串URL,位图图标){        super.onPageStarted(查看,网址,图标);
        prDialog = ProgressDialog.show(的getParent(),进行中,加载中,请稍候......);
    }    @覆盖
    公共无效onPageFinished(的WebView视图,字符串URL){
        Log.e(身份,叫......);
        super.onPageFinished(查看,网址);
        prDialog.dismiss();
        Log.e(身份,调用next ......);
    }
}

当连接按钮点击第二项活动将被执行并获得Facebook的page.But进度对话框停不下来。


解决方案

  @覆盖
        公共无效onPageFinished(的WebView视图,字符串URL){            尝试{
                    如果(prDialog.isShowing()|| prDialog!= NULL){
                        prDialog.dismiss();
                        prDialog = NULL; / *** ***添加/
                    }                    }赶上(例外的例外){
                        exception.printStackTrace();
                    }            }
        }

您还可以访问以下链接以获取完整的细节...

http://androiddubd.blogspot.com/2014/07/how-to-show-progress-dialog-or-loader.html

I am new to android.I am using progress dialog in my app but it could not stop.In my app i am using webview.In first activity I have connect button.In second activity connect to facebook code is available.In second activity code:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.facebook);
    wvFacebook.setWebViewClient(new MyWebViewClient()); 
    wvFacebook.loadUrl(strFacebook);
} 

private class MyWebViewClient extends WebViewClient 
{            
    public boolean shouldOverrideUrlLoading(WebView view, String url) 
    {
        view.getSettings().setJavaScriptEnabled(true);
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {

        super.onPageStarted(view, url, favicon);
        prDialog = ProgressDialog.show(getParent(), "In progress", "Loading, please wait...");
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        Log.e("status","calling....");
        super.onPageFinished(view, url);
        prDialog.dismiss();
        Log.e("status","calling next......");
    }
}

when connect button clicked the second activity will be executed and getting facebook page.But progress dialog could not stop.

解决方案

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

            try{
                    if (prDialog.isShowing()|| prDialog!= null) {
                        prDialog.dismiss();
                        prDialog= null; /*** Add ***/
                    }

                    }catch(Exception exception){
                        exception.printStackTrace();
                    }

            }
        }

You may also visit the following link to get a complete detail...

http://androiddubd.blogspot.com/2014/07/how-to-show-progress-dialog-or-loader.html

这篇关于进度对话框不能停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆