Android SmartRefreshLayout下拉刷新上拉加载动画不动解决

折腾了很久 该走的逻辑都走一切正常 但是动画效果就是没有 气死我了 一点一点删最后发现是有同名不同包的类导致的 气死
看清楚 不要采坑
错误示范

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

正确的 `

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

ok 希望大家少踩坑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 Android Studio 上使用第三方库实现上和下刷新的代码示例: 1. 添依赖库 在 app 的 build.gradle 文件中添以下依赖: ``` dependencies { implementation 'com.github.jdsjlzx:LRecyclerView:1.5.1' } ``` 2. 添布局文件 在布局文件中添 LRecyclerView 控件,例如: ``` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.example.recyclerviewdemo.view.LRecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> ``` 3. 初始化控件 在 Activity 或 Fragment 中初始化 LRecyclerView 控件,并设置上和下刷新的监听器,例如: ``` public class MainActivity extends AppCompatActivity { private LRecyclerView recyclerView; private MyAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); recyclerView = findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); adapter = new MyAdapter(this); recyclerView.setAdapter(adapter); recyclerView.setLoadingListener(new LRecyclerView.LoadingListener() { @Override public void onRefresh() { // 下刷新操作 // 在这里执行数据操作,完成后调用 recyclerView.refreshComplete() } @Override public void onLoadMore() { // 上操作 // 在这里执行数据操作,完成后调用 recyclerView.refreshComplete() } }); } } ``` 4. 自定义动画 可以通过自定义 View 来实现上和下刷新动画效果,具体实现方式可以参考 LRecyclerView 库中的 RefreshHeader 和 LoadingFooter 类。 以上就是使用 LRecyclerView 库实现上和下刷新的代码示例。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值