如何停止Android webView swipeToRefresh加载进度栏? [英] How to Stop Android webView swipeToRefresh loading progressbar?

查看:64
本文介绍了如何停止Android webView swipeToRefresh加载进度栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:已经在此处提出了此问题.没有得到任何答案,所以我决定用我的代码重新发布它.

Note: This question was already asked here. which did not get any answer so I decided to repost it with my code.

当用户从顶部下拉屏幕时,我希望webView刷新当前页面,但效果很好.问题是页面加载后加载进度栏没有停止.

I want a webView to refresh the current page when a user pulls down the screen from the top which is working fine. The problem is the loading progress bar isn't stopping after the page has been loaded.

这是 MainActivity.java

// Swipe to Refresh
        SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout)this.findViewById(R.id.swipeToRefresh);
        swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                myWebView.reload(); // refreshes the WebView
            }
        });
    }
@Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            progressBar.setVisibility(View.GONE);
            if (null != swipeLayout && swipeLayout.isRefreshing()) {
                swipeLayout.setRefreshing(false);
            }
        }

我已经更新了代码,但仍在加载中.

I have updated the code but it's still loading.

推荐答案

此问题已解决:

        final SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout)this.findViewById(R.id.swipeToRefresh);
        swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                myWebView.reload(); // refreshes the WebView

                if (null != swipeLayout) {
                    swipeLayout.setRefreshing(false);
                }
            }
        });

这篇关于如何停止Android webView swipeToRefresh加载进度栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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