davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.56k stars 552 forks source link

[Sticky headers]The real Header is invisiable #766

Open glooong opened 4 years ago

glooong commented 4 years ago

When I use the Sticky Header effect, the real Header is invisiable, like the picture. Why does this happen Below is my code: Header: open class MenuContentTitleItem(var titlePos: Int, private val menuContentAdapter: IMenuContentAdapterBridge) : AbstractHeaderItem() Adapter: init { contentAdapter.setDisplayHeadersAtStartUp(true) contentAdapter.setStickyHeaders(true) }

/**
 * Set data to notifyDataSetChanged.
 */
var data: T? = null
    set(value) {
        field = value
        navigatorAdapter.data = value
        setupContentAdapter()
    }

private fun setupContentAdapter() {
    contentAdapter.clear()

    val items = mutableListOf<AbstractFlexibleItem<*>>()
    val titleCount = getTitleItemCount()
    for (titleIndex in 0 until titleCount) {
        items.add(MenuContentTitleItem(titleIndex, contentAdapter))
        val subtitleCount = getSubtitleItemCount(titleIndex)
        for (subtitleIndex in 0 until subtitleCount) {
            items.add(MenuContentSubtitleItem(titleIndex, subtitleIndex, contentAdapter))
            val productCount = getProductItemCount(titleIndex, subtitleIndex)
            for (prodIndex in 0 until productCount) {
                items.add(MenuContentProductItem(titleIndex, subtitleIndex, prodIndex, contentAdapter))
            }
        }
    }
    contentAdapter.addItems(0, items)
}
222222 1111111