dimanche 3 décembre 2017

checkboxes in recyclerview get changed automatically by scrolling in android

ArrayList<HashMap<String, String>> hashMapArrayList;

public void onBindViewHolder(final EChallanRecyclerCardViewAdapter.ViewHolder holder, int position) {


 holder.cbSelectedchallans.setChecked(false);





        holder.cbSelectedchallans.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                if (isChecked) {
                    String cvTotChallanPayAmount= holder.tvChallanPayAmount.getText().toString().replace("₹","");
                    int TotChallanPayAmount=Integer.parseInt(cvTotChallanPayAmount);
                    TotaltoPay=TotaltoPay+TotChallanPayAmount;
                    Bundle bundle=new Bundle();
                    bundle.putInt("TotaltoPay",TotaltoPay);
                    Intent intent = new Intent("Add_Send_TotaltoPay");
                    intent.putExtras(bundle);
                    LocalBroadcastManager.getInstance(cntx).sendBroadcast(intent);



                } else {
                    if(TotaltoPay!=0) {
                        String cvTotChallanPayAmount = holder.tvChallanPayAmount.getText().toString().replace("₹", "");
                        int TotChallanPayAmount = Integer.parseInt(cvTotChallanPayAmount);
                        TotaltoPay = TotaltoPay - TotChallanPayAmount;
                        Bundle bundle=new Bundle();
                        bundle.putInt("TotaltoPay",TotaltoPay);
                        Intent intent = new Intent("Remove_Send_TotaltoPay");
                        intent.putExtras(bundle);
                        LocalBroadcastManager.getInstance(cntx).sendBroadcast(intent);

                    }
                }
            }
        });
}




Aucun commentaire:

Enregistrer un commentaire