나는이 alertdialog를 갖고 싶지만 두 번째 헤더를 두 개로 나눈다.어떻게하면 안드로이드에서 alertdialog에 두 번째 헤더를 만듭니 까?
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();
R.layout.your_content_view에 R.id.header 반드시 존재
물론 :
는 헤더 텍스트를 설정 마십시오. 'AlertDialog'는 일반적인 외모와 느낌을 가진 일반적으로 사용되는'Dialog' 객체를 만드는 편리한 메소드로 사용됩니다. – DeeV