Ich möchte diesen Alertdialog haben, aber mit einem zweiten Header, um die folgende Liste in zwei zu teilen. HierWie erstelle ich einen zweiten Header in Alertdialog in Android
This is how the alertdialog current looks
ist der Code:
final CharSequence[] items = {" Cereal ", " Chocolate chips ", " Crunchy peanut butter ", " Vanilla ", " Espresso powder ",
" Kosher salt ", " Powdered sugar ", " Marshmallows "};
// arraylist to keep the selected items
final ArrayList seletedItems = new ArrayList();
builder = new AlertDialog.Builder(this);
builder.setTitle("Ingredients List");
builder.setMultiChoiceItems(items, null,
new DialogInterface.OnMultiChoiceClickListener() {
// indexSelected contains the index of item (of which checkbox checked)
@Override
public void onClick(DialogInterface dialog, int indexSelected,
boolean isChecked) {
if (isChecked) {
// If the user checked the item, add it to the selected items
// write your code when user checked the checkbox
seletedItems.add(indexSelected);
} else if (seletedItems.contains(indexSelected)) {
// Else, if the item is already in the array, remove it
// write your code when user Uchecked the checkbox
seletedItems.remove(Integer.valueOf(indexSelected));
}
}
})
// Set the action buttons
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// Your code when user clicked on OK
// You can write the code to save the selected item here
}
});
dialog = builder.create();
Dieses eine benutzerdefinierte 'Dialog' erfordern würde. 'AlertDialog' wird häufig als eine bequeme Methode verwendet, um häufig verwendete 'Dialog'-Objekte mit gemeinsamen Aussehen und Gefühl zu erzeugen. – DeeV