gpt4 book ai didi

java - SwipeToRefreshview 滑动错误

转载 作者:行者123 更新时间:2023-11-30 00:23:52 26 4
gpt4 key购买 nike

我有滑动刷新 View 和滑动刷新 View 中的 ListView

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/txtEmpty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No data available"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:textSize="20sp"
android:visibility="gone"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">

</TextView>

<ListView
android:id="@+id/ArrayList"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="0dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toBottomOf="parent">

</ListView>
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.SwipeRefreshLayout>

我可以向下滚动列表,但当我想返回上一级时,滑动刷新功能开始,我必须能够查看整个列表,有什么建议吗??

这是监听器的实现

srl = (SwipeRefreshLayout) view.findViewById(R.id.refreshView);
srl.setOnRefreshListener(srfListener());

监听函数

protected SwipeRefreshLayout.OnRefreshListener srfListener() {
return new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
update();
}
};
}

和更新函数

@Override
protected void update() {
HomeActivity.getInstance().onResume();
srl.setRefreshing(false);
}

最佳答案

这样使用

 <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="match_parent">

<ListView
android:id="@+id/ArrayList"
android:scrollbars="vertical"
android:paddingBottom="85dp"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

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

关于java - SwipeToRefreshview 滑动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45768709/

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