全选购物车

//点击全选
holder.item3_CheckBox.setChecked(list.get(i).isChecked());
//点击全选
@Override
public void onClick(View view) {
switch (view.getId()){

        case R.id.all_chekbox:
            int allprice=0;
            int cont=0;
            boolean checked = all_chekbox.isChecked();
            for (int i=0;i<result.size();i++){
                result.get(i).setChecked(checked);
                int count = result.get(i).getCount();
                int price = result.get(i).getPrice();
                //allprice = allprice + (price * count);
                allprice+=(price * count);
                cont+=count;
            }
            if (!checked){
                allprice= (int) 0.0f;
                cont=0;
            }
            addprice1.setText( "¥:"+allprice+"");
            tv_go_to_pay.setText("数量:"+cont+"");
            myAdaptergouwu.setList(result);
            break;
    }

}

猜你喜欢

转载自blog.csdn.net/qq_42609613/article/details/89875042