I have one ListView with CheckBox, whenever user pressed the checkbox I'm getting some user information and stored in ArrayList. When unchecked the checkbox the user information remove from arraylist.
Now what's the problem is that sometimes it gives error:
java.lang.IndexOutOfBoundsException:
when unchecked the checkbox and application in unfortunately stops.
Code:
if (compoundButton.isChecked()) {
arrayList.get(arg0).setStatus(1);
barcode = arrayList.get(arg0).getBarcode();
proprice = arrayList.get(arg0).getPrice();
productname=arrayList.get(arg0).getItemName();
Listbarcode.add(barcode + "," + productname + "," + proprice);
} else {
if (Listbarcode.size() > 0){
Listbarcode.remove(arg0);
}
}
Aucun commentaire:
Enregistrer un commentaire