BaseRecyclerViewAdapterHelper GridLayoutManager BUG

ha5z0ras  于 2022-12-31  发布在  其他
关注(0)|答案(1)|浏览(171)
  1. 当前使用的版本号 3.0.1
  2. 复现操作描述 GridLayoutManager设置2列,加载数据时,若出现有单个item情况后,再次加载数据展示格式会异常,从第二行开始变成了LinerLayoutManager的样式
  3. 使用代码
    rv.setLayoutManager(new GridLayoutManager(this,2));
    MyListAdapter myListAdapter = new MyListAdapter(R.layout.item,list);
    rv.setAdapter(myListAdapter );

public class MyListAdapter extends BaseQuickAdapter<Bean, BaseViewHolder> {

public MyListAdapter(int layoutResId, List<Bean> data) {
    super(layoutResId, data);
}

@Override
protected void convert(BaseViewHolder baseViewHolder, Bean bean) {
    baseViewHolder.setText(R.id.item_name, bean.getName());
    SimpleDraweeView pic = baseViewHolder.getView(R.id.item_pic);
    pic.setImageURI(ApiConfig.URL+bean.getPhotoSrc());
}

}
4.gif复现效果

f0ofjuux

f0ofjuux1#

之前是每次都new新的list,然后new新的Adapter,现在改成了list.addAll , notifyDataSetChanged();
就没出现这种问题了

相关问题