Reputation: 470
I'm using the multispinner code that can be found in almost every topic asking about multispinners.
@Override
public boolean performClick() {
if (MainActivity.getSharedInstance().mp != null)
if (MainActivity.getSharedInstance().mp.isPlaying())
{
MainActivity.getSharedInstance().mp.stop();
//MainActivity.getSharedInstance().mp.release();
}
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setMultiChoiceItems(
items.toArray(new CharSequence[items.size()]), selected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (which == 0)
{
if (isChecked == true)
{
selected[0] = true;
selected[1] = false;
selected[2] = false;
selected[3] = false;
selected[4] = false;
selected[5] = false;
selected[6] = false;
selected[7] = false;
}
else
selected[0] = false;
}
else
{
if (isChecked == true)
{
selected[which] = true;
selected[0] = false;
}
else
selected[which] = false;
}
}
});
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.setOnCancelListener(this);
builder.show();
return true;
}
I want the multispinner to uncheck all other checkboxes if the first one is picked and to uncheck the first one when if anything else gets picked.
The result of my code above is that when I'm in the multispinner dialog it doesnt work, but if I check the first checkbox and close then reopen the multispinner then the other checkboxes get updated and are unchecked as I wanted.
How can I do this without needing to close and then reopen the multispinner dialog?
Thx for ur help.
Upvotes: 0
Views: 996
Reputation: 470
For everyone having the same problem use this to update the dialog:
((AlertDialog) dialog).getListView().setItemChecked(which, false);
Upvotes: 1