Skip to content

ViewPagerAdapter里的getItemCount计算不正确 #2

@wbkearly

Description

@wbkearly
override fun getItemCount(): Int {
    if (itemAdapter.getItemCount() == 0) return 0

    return (mItemCount / mSpanCount / mLineCount) + 1
}

比如 mItemCount=6, mSpanCount = 2, mLineCount = 3, 此时应该返回1 实际返回2

可以修改为

override fun getItemCount(): Int {
    return (mItemCount + mSpanCount * mLineCount - 1) / (mSpanCount * mLineCount);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions