I created a Dialog with single-choice list items:
final CharSequence[] items = {"Red", "Green", "Blue"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Colors");
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
alert.show();
How can I customize the layout of this dialog so that each list item in the dialog consists of a icon and a text. How to create custom layout for the list on the dialog?
Steps for Creating customize dialog:
Create the dialog box layout files, like:
Because the layout in the
ListViewcustom, so to create a layout file for theListView:Create a custom
DialogclassPriorityDlginherited fromDialogTo create a custom dialog box
Where
R.style.dlg_priorityset the dialog box uses the style file, just let the dialog box to remove the title bar, and of course you can code to complete this effect: