не означало делать это как ответ, но мне пришлось подробно остановиться на том, что вы сделали, чтобы сделать множественный выбор.Почему вы сделали переменную поля для вашего выбора?я только что сделал локальный SparseBooleanArray ...
public class NaughtyAndNice extends ListActivity {
TextView selection;
String[] items={"lorem","ipsum", "dolor", "sit", "amet",
"consectetuer", "adipisc", "jklfe", "morbi", "vel",
"ligula", "vitae", "carcu", "aliequet"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,items));
selection = (TextView)findViewById(R.id.selection);
this.getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
public void onListItemClick(ListView parent, View view, int position, long id){
SparseBooleanArray choices = parent.getCheckedItemPositions();
StringBuilder choicesString = new StringBuilder();
for (int i = 0; i < choices.size(); i++)
{
//added if statement to check for true. The SparseBooleanArray
//seems to maintain the keys for the checked items, but it sets
//the value to false. Adding a boolean check returns the correct result.
if(choices.valueAt(i) == true)
choicesString.append(items[choices.keyAt(i)]).append(" ");
}
selection.setText(choicesString);
}
}