使用RecyclerView实现底部翻页

本文介绍如何在Pad端App中使用RecyclerView替代addView方式,以解决大量页码加载缓慢的问题。通过RecyclerView的复用机制,实现了类似网页底部翻页的效果,优化了用户体验。
摘要由CSDN通过智能技术生成

最近在做pad端的app,需要一个像网页一样效果,之前使用addView方式,页码少的时候还可以,能实现效果,但是碰到了一个1000多页的界面,就GG了,页码半天显示不出来,于是使用RecyclerView作为容器,主要是看中RecyclerView的复用,不说了,看代码:

BottomPagerView xml布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal">


    <LinearLayout
        android:id="@+id/bottom_ll_content"
        android:layout_gravity="center_vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:layout_marginLeft="10px"
        android:layout_marginRight="10px"
        android:layout_marginTop="10px"
        android:orientation="horizontal">


        <Button
            android:id="@+id/pre_page"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/y5"
            android:paddingBottom="@dimen/x4"
            android:paddingLeft="@dimen/y5"
            android:paddingRight="@dimen/y5"
            android:paddingTop="@dimen/x4"
            android:text="上一页"
            android:textSize="@dimen/middlesize"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <Button
            android:id="@+id/next_page"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值