I make listview with checkbox and all work great, but when i try to get selected item even one item in click on button i fail.
This my code:
listSuacesAndOptions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l)
{
adapter.setCheckBox(position);
}
});
And Button:
finishPick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String test = "";
for(Item hold: adapter.getAllData()){
if(hold.isCheckbox()){
test += " " + hold.getName();
}
}
Toast.makeText(SuacesAndOptions.this,"Select: " + test,Toast.LENGTH_SHORT).show();
}
});
What can be wrong with my code? This show me only one word "Select" nothing else even i select all checkbox in listview
Aucun commentaire:
Enregistrer un commentaire