4

I would like to change the color of the positive button. How can I do this?

AlerDialog:

fun onSomeClicked(view: View) { val dialog: AlertDialog.Builder = AlertDialog.Builder(view.context) dialog.setTitle("SomeText") .setMessage("SomeMessage") .setPositiveButton(view.context.getString(R.string.ok_dialog)) { p0, p1 -> onCheckPassword(view) } .setNegativeButton(context.getString(R.string.cancel_dialog)) { p0, p1 -> } .create() .show() } 

Thanks! (My question is in kotlin, with do in kotlin.)

0

1 Answer 1

8

Some small changes will do the thing you want-

val builder: AlertDialog.Builder = AlertDialog.Builder(this) val dialog: AlertDialog = builder.setTitle("SomeText") .setMessage("SomeMessage") .setPositiveButton("OK") { dialog, which -> dialog.dismiss() } .setNegativeButton("Cancel") { dialog, which -> dialog.dismiss() } .create() dialog.show() dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLUE) dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.DKGRAY) 

hope it will be helpful.

Sign up to request clarification or add additional context in comments.

Comments