BaseQuickAdapter来自于BaseRecyclerViewAdapterHelper
public class TwoSelectGroupBean {
private String name;
private boolean isShwo;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isShwo() {
return isShwo;
}
public void setShwo(boolean shwo) {
isShwo = shwo;
}
}
public class TwoSelectTaskGroupAdapter extends BaseQuickAdapter<TwoSelectGroupBean> {
private int position = -1;
List<TwoSelectGroupBean> data;
public TwoSelectTaskGroupAdapter(List<TwoSelectGroupBean> data) {
super(R.layout.item_two_select_task_group,data);
this.data = data;
}
@Override
protected void convert(BaseViewHolder helper, TwoSelectGroupBean item) {
boolean isShow = false;
helper.setText(R.id.item_two_task_group_name,item.getName());
ImageView img = (ImageView) helper.getConvertView().findViewById(R.id.item_two_task_group_img);
ImageView del = (ImageView) helper.getConvertView().findViewById(R.id.item_two_task_group_del);
RelativeLayout layout = (RelativeLayout) helper.getConvertView().findViewById(R.id.item_two_task_group_layout);
if(item.isShwo()){
img.setVisibility(View.VISIBLE);
}else {
img.setVisibility(View.GONE);
}
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(position == -1){
LogUtil.e("执行了:position = -1");
for(int x = 0;x<data.size();x++) {
data.get(x).setShwo(false);
}
position = getViewHolderPosition(helper);
data.get(getViewHolderPosition(helper)).setShwo(true);
notifyDataSetChanged();
}else if(position == getViewHolderPosition(helper)){
position = -1;
LogUtil.e("执行了:取消");
data.get(getViewHolderPosition(helper)).setShwo(false);
notifyDataSetChanged();
}else if(position != getViewHolderPosition(helper)){
position = getViewHolderPosition(helper);
LogUtil.e("执行了:更改");
for(int x = 0;x<data.size();x++) {
data.get(x).setShwo(false);
}
data.get(getViewHolderPosition(helper)).setShwo(true);
notifyDataSetChanged();
}
}
});
del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
data.remove(getViewHolderPosition(helper));
notifyDataSetChanged();
}
});
}
/**侧拉删除条目中的点击事件*/
private OnClickLayouListener clickLayouListener;
public void setOnClickLayouListene(OnClickLayouListener clickLayouListener) {
this.clickLayouListener = clickLayouListener;
}
public interface OnClickLayouListener {
public void OnClickLayouListener(int position);
public void OnClickLayouListener(View view,int position);
}
}