SmartRefreshLayout icon indicating copy to clipboard operation
SmartRefreshLayout copied to clipboard

用classic的header和footer模拟微信消息列表(默认不能加载更多,可以下拉加载历史数据),当历史数据加载完毕,禁用下拉刷新,会导致列表滑动冲突

Open GHHMBird opened this issue 4 years ago • 4 comments

val srl = view.findViewById<SmartRefreshLayout>(R.id.srl) val recycler = view.findViewById<RecyclerView>(R.id.recycler)

    srl.setEnableLoadMore(false)
    srl.setOnRefreshListener {
        val list = ArrayList<Int>()
        for (index in 100..110) {
            list.add(index)
        }
        adapter.addData(0, list)
        srl.finishRefresh()
        if (adapter.list.size >= 50) {
            srl.setEnableRefresh(false)
        }
    }

    val list = ArrayList<Int>()
    for (index in 1..10) {
        list.add(index)
    }

    recycler.layoutManager = LinearLayoutManager(activity)
    adapter = activity?.let { MessageSystemListAdapter(it, list) }!!
    recycler.adapter = adapter

xml

<com.scwang.smart.refresh.layout.SmartRefreshLayout android:id="@+id/srl" android:layout_width="match_parent" android:layout_height="match_parent">

    <com.scwang.smart.refresh.header.ClassicsHeader
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.scwang.smart.refresh.footer.ClassicsFooter
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</com.scwang.smart.refresh.layout.SmartRefreshLayout>

GHHMBird avatar Mar 09 '21 02:03 GHHMBird

禁用下拉刷新的代码 不要立即执行,给一个延时执行,建议1秒的延时,具体也可以自己调试选择合适的延时时间

scwang90 avatar Mar 09 '21 11:03 scwang90

+1 使用 setEnableRefresh(false) 遇到同样场景问题,增加延迟后已解决

VictorChengSir avatar Mar 11 '21 05:03 VictorChengSir

延迟不稳定,下拉后快速滑动到顶部还是会触发的

naivewen avatar Jul 13 '25 02:07 naivewen

@scwang90 延迟1秒后,滑动还是有问题

ggyg123 avatar Aug 01 '25 08:08 ggyg123