如何停止 Android webView swipeToRefresh 加载进度条?
How to Stop Android webView swipeToRefresh loading progressbar?
注意:这个问题已经被问过 here. 但没有得到任何答案所以我决定用我的代码重新发布它。
我希望 webView 在用户从顶部下拉屏幕时刷新当前页面,效果很好。问题是页面加载后加载进度条没有停止。
这是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);
}
}
我已经更新了代码,但它仍在加载。
在 seOnRefreshListner 中将可见性设置为 progressBar,并在加载 webview 后停止刷新 swipeLayout。
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override public void onRefresh() { // Insert your code here
ProgressBar. SetVisibility(GONE);
if(null != swipeLayout) {
swipeLayout.setRefreshing(false);
}
myWebView.reload(); // refreshes the WebView
} });
更准确地说你试试代码
if (swipeLayout.isRefreshing()) {
swipeLayout.setRefreshing(false);
}
这已解决问题:
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);
}
}
});
注意:这个问题已经被问过 here. 但没有得到任何答案所以我决定用我的代码重新发布它。
我希望 webView 在用户从顶部下拉屏幕时刷新当前页面,效果很好。问题是页面加载后加载进度条没有停止。
这是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);
}
}
我已经更新了代码,但它仍在加载。
在 seOnRefreshListner 中将可见性设置为 progressBar,并在加载 webview 后停止刷新 swipeLayout。
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override public void onRefresh() { // Insert your code here
ProgressBar. SetVisibility(GONE);
if(null != swipeLayout) {
swipeLayout.setRefreshing(false);
}
myWebView.reload(); // refreshes the WebView
} });
更准确地说你试试代码
if (swipeLayout.isRefreshing()) {
swipeLayout.setRefreshing(false);
}
这已解决问题:
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);
}
}
});