StackLayoutManager
StackLayoutManager copied to clipboard
onBindViewHolder is called infinitely.
Hello,
onBindViewHolder is called infinitely for postition = 0
Hello,
I write Log.e(tag, msg)
at onBindViewHolder
method which on this sample's MainActivity.java
, but not found the scene what you desc,the log message list:
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 3
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 2
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 1
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 0
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 4
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 5
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 6
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 7
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 8
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 9
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 10
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 11
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 5
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 4
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 3
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 2
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 1
com.littlemango.stacklayoutmanagermaster E/mmmm: onBindViewHolder posision: 0
I am facing the same issue as @codefury described. Method onBindViewHolder() gets called multiple times when ever anything changes in adapter. Can you please assist me with this issue? Thankyou.
@ranasaha1212 I'm not sure about the specific situation, can you upload a reproducible demo?
`override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) {
mLayout?.requestLayout()
removeAndRecycleAllViews(recycler)
if (itemCount > 0) {
mScrollOffset = getValidOffset(mScrollOffset)
loadItemView(recycler)
}
}`
isWrong,dont need to removeAndRecyclerAllViews every time,should code like this: ` override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State) { if(hasInited) return mLayout?.requestLayout()
detachAndScrapAttachedViews(recycler)
if (itemCount > 0) {
mScrollOffset = getValidOffset(mScrollOffset)
loadItemView(recycler)
}
}`
detachAndScrapAttachedViews is useful and dont bindViewHolder everyTime