Hey guys
I'm creating an AlertDialog.Builder with the options of Yes, No, and Cancel. I've placed the code in the order I would like the buttons to be arranged in, but when I run an emulator the order is No, Cancel, Yes. How can I rearrange this?
You have three buttons: positive, neutral and negative (I think this is the order). You can rename them as you like.
@DarthFlarth :
Sample Code :
void methodInvokeBaseAlertDialog (object sender, EventArgs e) { var dlgAlert = (new AlertDialog.Builder (this)).Create (); dlgAlert.SetMessage ("Hello from alertDialog"); dlgAlert.SetTitle ("Alert Dialog"); dlgAlert.SetButton ("OK", handllerNotingButton); dlgAlert.SetButton2 ("Cancel", handllerNotingButton); dlgAlert.SetButton3 ("Nothing", handllerNotingButton); dlgAlert.Show (); } void handllerNotingButton (object sender, DialogClickEventArgs e) { AlertDialog objAlertDialog = sender as AlertDialog; Button btnClicked = objAlertDialog.GetButton (e.Which); Toast.MakeText (this, "you clicked on " + btnClicked.Text, ToastLength.Long).Show (); }
Output :
I think the 3 buttons are formatted as : positive, negative and neutral. You can do the assign the name and events of the button as you like.
Thanks for the help!
Just by complementing the friend's response:
@YkshLeo said:
@DarthFlarth : Sample Code : void methodInvokeBaseAlertDialog (object sender, EventArgs e) { var dlgAlert = (new AlertDialog.Builder (this)).Create (); dlgAlert.SetMessage ("Hello from alertDialog"); dlgAlert.SetTitle ("Alert Dialog"); dlgAlert.SetButton ("OK", handllerNotingButton); dlgAlert.SetButton2 ("Cancel", handllerNotingButton); dlgAlert.SetButton3 ("Nothing", handllerNotingButton); dlgAlert.Show (); } void handllerNotingButton (object sender, DialogClickEventArgs e) { AlertDialog objAlertDialog = sender as AlertDialog; Button btnClicked = objAlertDialog.GetButton (e.Which); Toast.MakeText (this, "you clicked on " + btnClicked.Text, ToastLength.Long).Show (); } Output : I think the 3 buttons are formatted as : positive, negative and neutral. You can do the assign the name and events of the button as you like.
In the button action, you can also use this way
alert.SetButton("Yes", (c, ev) => { //Action }); alert.SetButton2("No", (c, ev) => { //Action });>
Posts
You have three buttons: positive, neutral and negative (I think this is the order). You can rename them as you like.
@DarthFlarth :
Sample Code :
Output :
I think the 3 buttons are formatted as : positive, negative and neutral. You can do the assign the name and events of the button as you like.
Thanks for the help!
Just by complementing the friend's response:
@YkshLeo said:
In the button action, you can also use this way