You can use .setView()
to change the dialog layout.
It would look something like this:
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Closing")
.setView(R.layout.your_custom_layout)
.setPositiveButton("Yes", DialogInterface.OnClickListener { dialog, which -> finish() })
.setNegativeButton("No", null);
AlertDialog dialog = builder.create();
dialog.show();
//Here you can use dialog.findViewById()
}
Sorry I don't know Kotlin, but it will be similar.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…