- RecyclerView Bug:IndexOutOfBound
- RecyclerView Bug:IndexOutOfBound
- RecyclerView内部报错,刷新崩溃RecyclerVie
- recyclerview bug : IndexOutOfBou
- 安卓Tips之RecycleView下拉刷新数据的一个bug
- 解决ViewPager2嵌套RecyclerView滑动冲突的问
- Android之RecyclerView的原生Bug-Incon
- 解决RecyclerView使用smoothScrollToPo
- RecyclerView Bug:IndexOutOfBoun
- RecyclerView的Bug
1.创建一个类LinearLayoutManagerWrapper继承LinearLayoutManager,重写onLayoutChildren方法
public class WrapContentLinearLayoutManager extends LinearLayoutManager {
public WrapContentLinearLayoutManager(Context context) {
super(context);
}
public WrapContentLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public WrapContentLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}
2.设置RecyclerView的布局管理为WrapContentLinearLayoutManager对象
设置RecyclerView的布局管理为WrapContentLinearLayoutManager对象
网友评论