Alertdialog setItems with custom layout

When I use setItems with a custom layout, my layout appears below the item buttons (generated by setItems).

Is there a way to show custom layout on top and then item buttons? Or do I need to add item buttons to my own layout?

    AlertDialog.Builder myDialog = new AlertDialog.Builder(this);
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.alert_dialog_addons, null);
    myDialog.setTitle(title);

    myDialog.setView(layout); // WANT TO SHOW THIS ON TOP

    //THEN THIS
    myDialog.setItems(options, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            //DO SOMTHING
        }
    });
    myDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    myDialog.create().show();

      

+3


source to share





All Articles