I'm having requirement where i need to get the checkbox value count when i press a button. If the count is greater than 0 then i need to do some operations. I'm trying to do as below.
private int returncount(){
int cnt = 0;
SparseBooleanArray positions = xmlSyncItemsListView.getCheckedItemPositions();
int itemCount = xmlSyncItemsListView.getCount();
for(int i=0;i<itemCount;i++){
if(positions.get(i))
cnt++;
}
return cnt;
}
But i'm getting the positions variable in the above code as null. so it is throwing the expection saying trying assign value to the null variable.
I'm also restoring the value of checkbox ie. when i close the application and open it, the checkbox value is retored.
Could you please help me with this.
Aucun commentaire:
Enregistrer un commentaire