我正在开发一个 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();
}
}
.
.
.
}
加载圈永远不会像下面的截图那样隐藏起来
我的代码有什么问题,我该如何解决?
最佳答案
刷新后必须set refresh
为false
refresher.setRefreshing(false);
更新:
Kotlin :
refresher.isRefreshing = false
关于android - SwipeRefreshLayout 加载圈没有隐藏在Android中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35378734/