- 当前使用的版本号 3.0.1
- 复现操作描述 GridLayoutManager设置2列,加载数据时,若出现有单个item情况后,再次加载数据展示格式会异常,从第二行开始变成了LinerLayoutManager的样式
- 使用代码
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复现效果
1条答案
按热度按时间f0ofjuux1#
之前是每次都new新的list,然后new新的Adapter,现在改成了list.addAll , notifyDataSetChanged();
就没出现这种问题了