android - SwipeRefreshLayout 加载圈没有隐藏在Android中

标签 android listview

我正在开发一个 Android 应用程序。我将 listview 与 SwipefreshLayout 一起使用。但是当我使用 SwipefreshLayout 刷新 ListView 时,加载圈永远不会被隐藏起来。我在 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>

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

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

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

最佳答案

刷新后必须set refreshfalse

refresher.setRefreshing(false);

From doc

更新:
Kotlin :

refresher.isRefreshing = false

关于android - SwipeRefreshLayout 加载圈没有隐藏在Android中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35378734/

相关文章:

android - 向后兼容的 Android 应用程序?

java - 卡尔曼滤波器和内部状态变量的质量

android - 如何以编程方式设置 textview-s 及其属性?

android - 如何创建点对点连接?

javascript - react native : Touchable Opacity element is clickable on iOS but not Android

JavaFX ListView setItems() 无法解析符号

java - 如何在Android ListView中加载list_item_event.xml?

android - 来自网络的具有不同高度的图像的 ListView 导致 "flickers"

python - Django - 如何在发布表单时添加用户的 IP 地址

ScrollView 内的 Android ListView