<LinearLayout
android:id="@+id/ll_mycollection_bottom_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:visibility="gone"
android:background="@color/app_bg">
<View
android:background="#e5e5e5"
android:layout_width="match_parent"
android:layout_height="1px"/>
<RelativeLayout
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="@dimen/px_90">
<TextView
android:layout_centerVertical="true"
android:id="@+id/tv"
android:textColor="#1A1A1A"
android:textSize="@dimen/px_28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/px_30"
android:text="@string/mine_certify_select" />
<TextView
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/tv"
android:textColor="#1A1A1A"
android:textSize="@dimen/px_28"
android:id="@+id/tv_select_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/px_18"
android:text="0" />
<Button
android:textColor="@color/color_b7b8bd"
android:textSize="@dimen/px_28"
android:layout_centerVertical="true"
android:background="@drawable/button__noclickable_shape"
android:gravity="center"
android:id="@+id/btn_delete"
android:layout_width="@dimen/px_160"
android:layout_height="@dimen/px_66"
android:layout_marginRight="@dimen/px_30"
android:layout_alignParentRight="true"
android:text="删除" />
<TextView
android:layout_centerVertical="true"
android:id="@+id/select_all"
android:layout_marginRight="@dimen/px_30"
android:background="@drawable/bg_selete_all"
android:layout_toLeftOf="@+id/btn_delete"
android:layout_width="@dimen/px_160"
android:layout_height="@dimen/px_66"
android:text="全选"
android:gravity="center"
android:textColor="#000001"
android:textSize="@dimen/px_28"/>
</RelativeLayout>
</LinearLayout>
<ImageView android:id="@+id/check_box" android:src="@mipmap/ic_uncheck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/px_24" android:gravity="center" android:visibility="gone"/>
public void notifyAdapter(List<MyLiveList.MyLive> myLiveList,boolean isAdd){
if (!isAdd){
this.mMyLiveList=myLiveList;
}else {
this.mMyLiveList.addAll(myLiveList);
}
notifyDataSetChanged();
}
mAdapter.notifyAdapter(data.getList(), false);
public List<MyLiveList.MyLive> getMyLiveList(){
if (mMyLiveList == null) {
mMyLiveList =new ArrayList<>();
}
return mMyLiveList;
}
private static final int MYLIVE_MODE_CHECK = 0;
private static final int MYLIVE_MODE_EDIT = 1;
//点击编辑的时候显示,顺便调mAdapter.setEditMode(mEditMode);赋值
mEditMode = mEditMode == MYLIVE_MODE_CHECK ? MYLIVE_MODE_EDIT : MYLIVE_MODE_CHECK;
if (mEditMode == MYLIVE_MODE_EDIT) {
activity_btn.setText("取消");
ll_mycollection_bottom_dialog.setVisibility(View.VISIBLE);
editorStatus = true;
} else {
activity_btn.setText("编辑");
ll_mycollection_bottom_dialog.setVisibility(View.GONE);
editorStatus = false;
onRefresh();
}
mAdapter.setEditMode(mEditMode);
//当然,adapter中也有先关的变量在记录
private static final int MYLIVE_MODE_CHECK = 0;
int mEditMode = MYLIVE_MODE_CHECK;
public void setEditMode(int editMode) {
mEditMode = editMode;
notifyDataSetChanged();
}
//在onBindViewHolder中做显示和隐藏的操作.
holder.setIsRecyclable(false); // 为了条目不复用
//显示和隐藏
if (mEditMode == MYLIVE_MODE_CHECK) {
holder.mCheckBox.setVisibility(View.GONE);
} else {
holder.mCheckBox.setVisibility(View.VISIBLE);
public boolean isSelect;
public boolean isSelect() {
return isSelect;
}
public void setSelect(boolean isSelect) {
this.isSelect = isSelect;
}
//然后点击条目选中和不选中的时候为Imageview设置不同的图片
if(myLive.isSelect()) {
holder.mCheckBox.setImageResource(R.mipmap.ic_checked);
}else{
holder.mCheckBox.setImageResource(R.mipmap.ic_uncheck);
}
//在adapter中暴漏一个Item的点击事件的接口
public interface OnSwipeListener {
void onItemClickListener(int pos,List<MyLiveList.MyLive> myLiveList);
}
/*
在activity中的item点击事件中,来操作Imageview是否选中
*/
//用一个变量记录
private int index = 0;
MyLive myLive = myLiveList.get(pos);
boolean isSelect = myLive.isSelect();
if (!isSelect) {
index++;
myLive.setSelect(true);
if (index == myLiveList.size()) {
isSelectAll = true;
selectAll.setText("取消全选");
}
} else {
myLive.setSelect(false);
index--;
isSelectAll = false;
selectAll.setText("全选");
}
setBtnBackground(index);
tv_select_num.setText(String.valueOf(index));
radioAdapter.notifyDataSetChanged();
/**
* 根据选择的数量是否为0来判断按钮的是否可点击.
*
* @param size
*/
private void setBtnBackground(int size) {
if (size != 0) {
mBtnDelete.setBackgroundResource(R.drawable.button_shape);
mBtnDelete.setEnabled(true);
mBtnDelete.setTextColor(Color.WHITE);
} else {
mBtnDelete.setBackgroundResource(R.drawable.button__noclickable_shape);
mBtnDelete.setEnabled(false);
mBtnDelete.setTextColor(ContextCompat.getColor(this, R.color.color_b7b8bd));
}
}
if (radioAdapter == null) return;
if (!isSelectAll) {
for (int i = 0, j = radioAdapter.getMyLiveList().size(); i < j; i++) {
radioAdapter.getMyLiveList().get(i).setSelect(true);
}
index = radioAdapter.getMyLiveList().size();
mBtnDelete.setEnabled(true);
selectAll.setText("取消全选");
isSelectAll = true;
} else {
for (int i = 0, j = radioAdapter.getMyLiveList().size(); i < j; i++) {
radioAdapter.getMyLiveList().get(i).setSelect(false);
}
index = 0;
mBtnDelete.setEnabled(false);
selectAll.setText("全选");
isSelectAll = false;
}
radioAdapter.notifyDataSetChanged();
setBtnBackground(index);
tv_select_num.setText(String.valueOf(index));
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有