I have a recyclerview with checkbox list items. Now I scroll to end of recyclerview and click ckeckbox. When I click checkbox recyclerview get jerk and list moved to little top to the list.
Here I post my Adapter code for your review.
@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
holder.mChkEquipments.setOnCheckedChangeListener(null);
holder.txt_equiment_number.setVisibility(View.INVISIBLE);
holder.divider.setVisibility(View.INVISIBLE);
if(position==0){
holder.txt_equiment_number.setVisibility(View.VISIBLE);
holder.text_hookEqmnt.setText(mArrayList.get(position).getInspectionName());
holder.divider.setVisibility(View.VISIBLE);
holder.txt_equiment_number.setText(mEquipmentNumber);
}else{
holder.text_hookEqmnt.setText(mArrayList.get(position).getInspectionName());
}
holder.text_hookEqmnt.setText(mArrayList.get(position).getInspectionName());
holder.txt_equiment_number.setText(mEquipmentNumber);
holder.mChkEquipments.setChecked(mArrayList.get(position).getInspectionStatus());
if(mArrayList.get(position).getInspectionStatus()){
holder.mChkEquipments.setButtonDrawable(R.drawable.route_check);
}else{
holder.mChkEquipments.setButtonDrawable(R.drawable.route_close);
}
holder.mChkEquipments.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
/*holder.mChkEquipments.setChecked(isChecked);
mArrayList.get(position).setInspectionStatus(isChecked);
updateStatus(mArrayList.get(position).getId(),isChecked);
if(isChecked){
holder.mChkEquipments.setButtonDrawable(R.drawable.route_check);
}else{
holder.mChkEquipments.setButtonDrawable(R.drawable.route_close);
}*/
}
});
if (position % 2 != 0) {
holder.mVIew.setBackgroundResource(R.color.list_alternative_bg);
} else {
holder.mVIew.setBackgroundResource(R.color.white);
}
}
And also I tried with OnClickListener too. But Same problem I am facing.
holder.mChkEquipments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final boolean isChecked = holder.mChkEquipments.isChecked();
holder.mChkEquipments.setChecked(isChecked);
mArrayList.get(position).setInspectionStatus(isChecked);
updateStatus(mArrayList.get(position).getId(),isChecked);
if(isChecked){
holder.mChkEquipments.setButtonDrawable(R.drawable.route_check);
}else{
holder.mChkEquipments.setButtonDrawable(R.drawable.route_close);
}
}
});
Please help me to resolve my issue.
Aucun commentaire:
Enregistrer un commentaire