I have a webview within a fragment and I would like to add a swipe to update the page that is displayed. I have seen several examples but none of them work for me.
This is my xml :
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/web_fauna"
android:layout_width="match_parent"
android:layout_height="match_parent">
</WebView>
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:id="@+id/prgFauna"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
/>
and it is the .java of that fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v=inflater.inflate(R.layout.fragment_fauna, container, false);
progressBar=v.findViewById(R.id.prgFauna);
final WebView webView=(WebView)v.findViewById(R.id.web_fauna);
webView.getSettings().setJavaScriptEnabled(true); //activar javascript
webView.setWebViewClient(new WebViewClient(){ //abrir url en la app y circulo de carga
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
});
webView.loadUrl("http://www.vivecolbun.com/fauna.html");
return v;
}
I hope you can help me