首页 > 解决方案 > webview的iframe下拉刷新

问题描述

如何在 Android 中刷新 web 视图。里面有一个 webview iframe。当我使用 NestedScrollView 时,它会无限滚动。即使我正在检查 y 方向的滚动值,它总是给我 0 但实际上它的实际值不是 0。

布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:id="@+id/nonVideoLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:windowSoftInputMode="adjustResize">

        <WebView
            android:id="@+id/home_activity_webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:windowSoftInputMode="adjustResize"
            app:layout_constraintDimensionRatio="1" />

    </RelativeLayout>

</android.support.v4.widget.SwipeRefreshLayout>

标签: androidiframeandroid-webviewswiperefreshlayout

解决方案


当下拉 webView 时,在 Swipe Refresh 方法中调用 URL。

      swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {

                //Call your URL again here

            }
        });

推荐阅读