Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display header as one row in GridLayoutMnager #206

Open
alirezaeiii opened this issue Nov 29, 2021 · 0 comments
Open

Display header as one row in GridLayoutMnager #206

alirezaeiii opened this issue Nov 29, 2021 · 0 comments

Comments

@alirezaeiii
Copy link

I am trying to show header as one row in Paging3 library using GridLayoutManager. For the footer as one row, I made following implementation :

            val header = LoadStateAdapter { showAdapter.retry() }
            binding.list.apply {
                val layoutManager = layoutManager as GridLayoutManager
                layoutManager.spanSizeLookup = object : SpanSizeLookup() {
                    override fun getSpanSize(position: Int): Int {
                        return if (showAdapter.getItemViewType(position) == ShowAdapter.LOADING_ITEM)
                            1 else layoutManager.spanCount
                    }
                }
                adapter = showAdapter.withLoadStateHeaderAndFooter(
                    header = header,
                    footer = LoadStateAdapter { showAdapter.retry() }
                )
            }

And in the Adapter, I have following implementation :

 override fun getItemViewType(position: Int): Int {
            return if (position == itemCount) SHOW_ITEM else LOADING_ITEM
}

How about header? How can I display it in one row?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant