第一次写博客记录自己的成长,有错希望指出,主要是实现点击编辑按钮后列表项前面出现checkbox点击后执行批量删除
实现方式:自定义adapter
1 点击编辑:
public
void
onClick(View arg0) {
if
(
tvTit.getText().equals(
"编辑")) {
delete.setVisibility(View.
VISIBLE);
isiblecheck
=
true;
adapter.notifyDataSetChanged();
tvTit.setText(
"取消");
}
else
{
tvTit.setText(
"编辑");
delete.setVisibility(View.
GONE);
visiblecheck
=
false;
}
2 adapter里:
if(PersonalCenter_CourseActivity.visiblecheck){
holder.
bt_compile.setVisibility(View.
VISIBLE);
}
else{
holder.
bt_compile.setVisibility(View.
GONE)
}
3 CheckBox点击事件:
holder.bt_compile
.setOnCheckedChangeListener(new
OnCheckedChangeListener() {
@Override
public
void
onCheckedChanged(CompoundButton buttonView,
boolean
isChecked) {
array[position] = isChecked;
}
});
4 初始化adapter:
barray
=
new
boolean[dataList.size()];
for
(
int
i = 0; i <
dataList.size(); i++) {
barray[i] =
false;
}
System.
out.println(
barray.
length);
public
ItemContentAdapter(Context context, List<Course> datas,boolean[]
array) {
this.
mInflater
= LayoutInflater.
from(context);
this.
datas
=
datas;
this.
array
= array;
}