gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 00:11:25 45 4
gpt4 key购买 nike

我正在开发一个 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/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com