Bug 985875 - Set selected item in adapter for single select lists. r=bnicholson

This commit is contained in:
Wes Johnston 2014-03-25 22:44:08 -07:00
parent 7332c1b9f8
commit bef2c90b3f

View File

@ -268,6 +268,15 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis
builder.setSingleChoiceItems(mAdapter, mAdapter.getSelectedIndex(), new DialogInterface.OnClickListener() { builder.setSingleChoiceItems(mAdapter, mAdapter.getSelectedIndex(), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
// The adapter isn't aware of single vs. multi choice lists, so manually
// clear any other selected items first.
ArrayList<Integer> selected = mAdapter.getSelected();
for (Integer sel : selected) {
mAdapter.toggleSelected(sel);
}
// Now select this item.
mAdapter.toggleSelected(which);
closeIfNoButtons(which); closeIfNoButtons(which);
} }
}); });