在Android中,SwipeRefreshLayout的加载圆圈不会隐藏

3
我是一个开发安卓应用的人。我正在使用listview和SwipefreshLayout。但是当我使用SwipefreshLayout刷新list view时,加载圆圈永远不会被隐藏。我在fragment中使用它。
这是布局文件:
<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>

这是我在碎片中使用它的方式。
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();
    }

}
.
.
.
}

加载圆圈从未像下面的截图那样被隐藏

enter image description here

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

1个回答

10
你需要在刷新后将设置刷新设为false
refresher.setRefreshing(false);

来自文档

更新:
Kotlin:

refresher.isRefreshing = false

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接