Issue
I am trying to set up a pull to refresh feature like chrome (swipe refresh layout). The loading bar disappears after pull. How can i fix this?
I've tried various code samples from stack overflow... but none of them seem to work. Swipe to refresh works but disappears right after pull.
Swipe refresh in main activity java
mySwipeRefreshLayout = this.findViewById(R.id.swipeContainer);
mySwipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
browser.reload();
mySwipeRefreshLayout.setRefreshing(false);
}
}
);
I Just want the loading icon to load till the full page is refreshed like chrome.
Solution
if you want to keep the loading till the page loaded you don't have to use mySwipeRefreshLayout.setRefreshing(false) inside your refresh listener , because your are disabling it just after the refresh start.
instead you have to use it when your loading is done . let say as example you have a webview , so you should listen on the webview progress like this example :
mWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
mySwipeRefreshLayout.setRefreshing(false);
}
});
Answered By - ismail alaoui
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.