public class QuickExpandableAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {
public static final int TYPE_LEVEL_0 = 0;
public static final int TYPE_LEVEL_1 = 1;
/**
* Same as QuickAdapter#QuickAdapter(Context,int) but with
* some initialization data.
*
* @param data A new list is created out of this one to avoid mutable list
*/
public QuickExpandableAdapter(List<MultiItemEntity> data) {
super(data);
addItemType(TYPE_LEVEL_0, R.layout.view_expand_0);
addItemType(TYPE_LEVEL_1, R.layout.view_expand_1);
public class QuickExpandableAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> { public static final int TYPE_LEVEL_0 = 0; public static final int TYPE_LEVEL_1 = 1;
// addItemType(TYPE_LEVEL_1, R.layout.list_item_top); }
// ToastUtils.showTastyInfo("收起:" + item0.getTitle()); }else { expand(pos); // ToastUtils.showTastyInfo("展开:" + item0.getTitle()); } } }); break; case TYPE_LEVEL_1: int parentPosition = getParentPosition(item); TitleExpandItem titleExpandItem = (TitleExpandItem) getData().get(parentPosition); RecyclerView recyclerView = helper.getView(R.id.expand_list_item1_tv); BaseQuickAdapter baseQuickAdapter = new BaseQuickAdapter<PopItemModel,BaseViewHolder>(R.layout.grid_item,titleExpandItem.getSubItems()) { @Override protected void convert(BaseViewHolder helper, PopItemModel item) { TextView tv_title = helper.getView(R.id.tv_title); tv_title.setText(item.item); helper.addOnClickListener(R.id.tv_title); if (item.isSelect){ tv_title.setBackgroundResource(R.drawable.text_bg3); }else{ tv_title.setBackgroundResource(R.drawable.text_bg2); } } }; recyclerView.setLayoutManager(new GridLayoutManager(mContext,3)); recyclerView.setAdapter(baseQuickAdapter);
// if (R.id.tv_title == view.getId()){ // for (int i = 0; i < item1.list.size(); i++) { // if (position == i){ // item1.list.get(i).isSelect = true; // }else{ // item1.list.get(i).isSelect = false; // } // } // } // baseQuickAdapter.notifyDataSetChanged(); } }); break; } } }
我adapter如上,但是当点击一个数据的时候,本来是这样的数据结构的。 点击后,数据自己变成这样了。 请问是怎么回事啊?我调试了好久都没找到问题,而且我根本没改变过数据。数据结构在点击就变了。