0

I am using webview in android i have implemented pull to refresh in webview. Also i have created a class that handles the external links inside the website to open the links within the app only but the problem is reloader keeps on loading like this

enter image description here

xml file of webview fragment

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <WebView
            android:id="@+id/Zomato"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            />
    </android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

SwipeLayout in the Desc.java

     SwipeRefreshLayout swipe;
     static WebView webView;
      @Override
      public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

     webView=view.findViewById(R.id.Zomato);

    swipe=view.findViewById(R.id.swipe2);
}
    swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {

                String url = "https://www.zomato.com/";
                webView.setWebViewClient(new WebViewClient() {
                    @Override
                    public void onPageFinished(WebView view, String url) {
                        swipe.setRefreshing(false);
                    }
                });
             }



webView.setWebViewClient(new Fragment2.GeoWebViewClient());
nikhil arora
  • 29
  • 1
  • 8

1 Answers1

1

Hi Actually you are doing wrong because here you are setting web view client tow time means it will override first one so please set only first time and put logic in that onPageFinished it will work. Referer bellow answer

https://stackoverflow.com/a/6720004/3894930

Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39