SwipeRefreshLayout 加载圈未隐藏在 Android 中

Wai*_*ein 2 android listview

我正在开发一个 Android 应用程序。我将列表视图与 SwipefreshLayout 一起使用。但是当我使用 SwipefreshLayout 刷新列表视图时,加载圈永远不会隐藏。我在片段中使用它。

这是布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipe_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- place your view here -->

            <ListView
                android:dividerHeight="@dimen/list_item_divider_height"
                android:padding="@dimen/list_padding"
                android:divider="@color/whitesmoke"
                android:id="@+id/listview_podcast_list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></ListView>

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

        <TextView
            android:layout_below="@+id/swipe_refresh_layout"
            android:textSize="17dp"
            android:textStyle="bold"
            android:textColor="@color/black"
            android:textAlignment="center"
            android:id="@+id/tf_no_records"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这就是我在片段中使用它的方式

public class PodcastListFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
    // property variables here

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


.
.
.

refresher = (SwipeRefreshLayout)view.findViewById(R.id.swipe_refresh_layout);
        refresher.setOnRefreshListener(this);

return view;

}

@Override
    public void onRefresh() {
        refreshListView();
    }

}
.
.
.
}
Run Code Online (Sandbox Code Playgroud)

加载圈永远不会被隐藏,如下面的截图所示

在此处输入图片说明

我的代码有什么问题,我该如何解决?

Kau*_*hik 7

你必须set refreshingfalse经过刷新

refresher.setRefreshing(false);
Run Code Online (Sandbox Code Playgroud)

来自文档

更新:
科特林:

refresher.isRefreshing = false
Run Code Online (Sandbox Code Playgroud)