I am trying to use several selectable dialog boxes as the code below. And I want to use the neutral button to deselect all the items in the list. But when you click a button in a dialog box, the dialog disappears immediately, I assume that this should be the default action. But I want to stay, as the user does not expect such an action, which I think. Is it possible to avoid the disappearance of the dialog when you click a button on it or to create a custom dialog?
protected Dialog onCreateDialog( int index)
{
return new AlertDialog.Builder(this)
.setTitle( "title" )
.setMultiChoiceItems(items, selections, new DialogInterface.OnMultiChoiceClickListener(){
@Override
public void onClick( DialogInterface dialog, int clicked, boolean selected ) { }
})
.setPositiveButton( "OK", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int id)
{
}
})
.setNeutralButton( "Deselect all", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int id)
{
}
})
.create();
}
Thanks in advance, yokyo
source
share