【问题标题】:SwipeRefreshLayout and to handle external links in webview( manual class) not working together in android webviewSwipeRefreshLayout 和处理 webview 中的外部链接(手动类)在 android webview 中不能一起工作
【发布时间】:2018-11-11 03:19:41
【问题描述】:

我在 android 中使用 webview,我已经在 webview 中实现了拉取刷新。我还创建了一个类来处理网站内的外部链接,以仅打开应用程序内的链接,但问题是重新加载器继续像这样加载

webview片段的xml文件

<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>

Desc.java 中的 SwipeLayout

     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());

【问题讨论】:

    标签: android android-studio android-fragments webview swiperefreshlayout


    【解决方案1】:

    你好实际上你做错了,因为你在这里设置 web 视图客户端拖时间意味着它将覆盖第一个,所以请只设置第一次并将逻辑放入 onPageFinished 它将起作用。参考下面的答案

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-05
      • 2012-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      相关资源
      最近更新 更多