In my application I am having a list view,Now the problem is I want to get the marked positions
the code I am using is
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("Entered Delete Button");
String selected = "";
int cntChoice = lv.getCount();
System.out.println("The Number Of Contacts"+cntChoice);
SparseBooleanArray x = lv.getCheckedItemPositions();
System.out.println(x);
for(int i = 0; i < cntChoice; i++){
if(x.get(i)) {
selected += lv.getItemAtPosition(i).toString() + "\n";
}
}
Toast.makeText(ViewSelectedContacts.this,
selected,
Toast.LENGTH_LONG).show();
}
});
The problem is SparseBooleanArray is not populating with the element
Also i had added
android:choiceMode="multipleChoice"
in the listview..Somebody please help me to fin the problem
1 Answer