-2
我有一個recyclerview複選框列表項。現在我滾動到recyclerview結束並單擊cckckbox。當我點擊複選框recyclerview得到混蛋和列表移動到小頂部的名單。recyclerview得到混蛋,而我點擊複選框
在這裏我張貼我的適配器代碼供您審查。
@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);
}
}
而且我也嘗試過使用OnClickListener。但我面臨同樣的問題。
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);
}
}
});
請幫我解決我的問題。
請問我可以知道投票的原因是什麼? – Vijay
看看谷歌io 2017 UI表現會議,瞭解如何「去看看」您的應用...我敢打賭'updateStatus' – Selvin
當然。我會查的。 – Vijay