I have a button and I would like to open a dialog when pressed. This is my code:
Button more = (Button) findViewById(R.id.more);
more.setOnClickListener(new
Aman Alam's souliton is good, but the .setButton()
part gave me an error. So I implemented it in kotlin and fixed the error.
val dialog = AlertDialog.Builder(this)
dialog.setTitle("Title")
.setMessage("Write your message here.")
.setPositiveButton("YES") { dialog, whichButton ->
// DO YOUR STAFF
}
.setNegativeButton("NO") { dialog, whichButton ->
// DO YOUR STAFF
// dialog.close()
}
dialog.show()
More about dialogs: https://developer.android.com/guide/topics/ui/dialogs