In the Android docs on AlertDialog, it gives the following instruction and example for setting a custom view in an AlertDialog:
If you want to display a
It would make the most sense to do it this way, least amount of code.
new AlertDialog.Builder(this).builder(this)
.setTitle("Title")
.setView(R.id.dialog_view) //notice this setView was added
.setCancelable(false)
.setPositiveButton("Go", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
EditText textBox = (EditText) findViewById(R.id.textbox);
doStuff();
}
}).show();
For an expanded list of things you can set, start typing .set
in Android Studio