Giter Site home page Giter Site logo

Comments (6)

shenbengit avatar shenbengit commented on May 24, 2024

这个需求可以自己实现,回调当前页面的页数的时候,自己计算。

from pagergridlayoutmanager.

LxzBUG avatar LxzBUG commented on May 24, 2024

每页6个数据的话,currentPagerIndex ==1的时候,就是0-5正在显示,其他都是不可见。currentPagerIndex=2时,就是6-11。是这个思路去写吗

from pagergridlayoutmanager.

shenbengit avatar shenbengit commented on May 24, 2024

对,还要考虑不满一页的情况

from pagergridlayoutmanager.

LxzBUG avatar LxzBUG commented on May 24, 2024

`
public List getPage(List list, int pageIndex) {
int pageSize = 6; // 每页元素个数
int fromIndex = (pageIndex - 1) * pageSize; // 当前页起始元素下标
if (fromIndex >= list.size()) {
return new ArrayList(); // 当前页无元素,返回空列表
}
int toIndex = Math.min(fromIndex + pageSize, list.size()); // 当前页结束元素下标
return list.subList(fromIndex, toIndex); // 返回当前页元素列表
}

`

可以了

from pagergridlayoutmanager.

LxzBUG avatar LxzBUG commented on May 24, 2024

RecyclerView's width and height must be exactly

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_list"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_centerInParent="true"
android:background="@android:color/transparent" />

        指定了宽高还是崩溃了

from pagergridlayoutmanager.

shenbengit avatar shenbengit commented on May 24, 2024

RecyclerView的父布局是什么?

from pagergridlayoutmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.