Я хотел бы иметь этот alertdialog, но со вторым заголовком, чтобы разделить следующий список на две части.Как создать второй заголовок в alertdialog в android
This is how the alertdialog current looks
Вот код:
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();
Это потребует обычай 'Dialog'. «AlertDialog» в значительной степени используется в качестве удобного метода для создания обычно используемых объектов «Dialog» с общими взглядами и ощущениями. – DeeV