Skip to content Skip to sidebar Skip to footer

Dialog With Own Layout In Android

I have a screen where I have some buttons. I would like to know how can I do something like that: when I click on button app show me dialog with my interface where I can writer tex

Solution 1:

yes you can actualy inflate a layout and produce it in an alert dialog

       LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
        returnnew AlertDialog.Builder(AlertDialogSamples.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setTitle(R.string.alert_dialog_text_entry)
            .setView(textEntryView)
            .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
                publicvoidonClick(DialogInterface dialog, int whichButton) {

                    /* User clicked OK so do some stuff */
                }
            })
            .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
                publicvoidonClick(DialogInterface dialog, int whichButton) {

                    /* User clicked cancel so do some stuff */
                }
            })
            .create();

this is from the sample code provided in the api samples

Post a Comment for "Dialog With Own Layout In Android"