c# - Setting dialog button clicklistener in Android Xamarin -


i want display dialog alert in xamarin android app (c#), , want stuff dialog when click on buttons.

from before, use code:

alertdialog.builder builder = new alertdialog.builder(this)     .settitle("delete")     .setmessage("are sure want delete?)     .setpositivebutton("no", (senderalert, args) => { })     .setnegativebutton("yes", (senderalert, args) => {     databasehelper.delete(item); }); builder.create().show(); 

to make random example, lets want keep dialog box open until item deleted, want disable yes button , change message text while android working. possible code have access dialog , change it? neither senderalert nor args have useful properties or methods.

i have been looking other ways build dialog, , have seen these two:

1) this guy using way bellow, dialoginterface not have .onclicklistener()

builder.setpositivebutton("test",  new dialoginterface.onclicklistener() {     @override     public void onclick(dialoginterface dialog, int which)     {         //do stuff dialog     } }); 

2) this guy using idialoginterfaceonclicklistener, , have been trying find example of how way, havent found any. seems using null instead of code want.

.setpositivebutton("ok", (android.content.idialoginterfaceonclicklistener)null) 

any ideas?

i use this:

      using (var builder = new alertdialog.builder(activity))       {          var title = "please edit details:";          builder.settitle(title);          builder.setpositivebutton("ok", okaction);          builder.setnegativebutton("cancel", cancelaction);          var mycustomdialog = builder.create();           mycustomdialog.show();       }        private void okaction(object sender, dialogclickeventargs e)       {          var mybutton = sender button; //this give ok button on dialog you're in here don't need - perform action want directly unless i'm missing something..          if(mybutton != null)          {              //do on ok selected          }       }       private void cancelaction(object sender, dialogclickeventargs e)       {          //do on cancel selected       } 

example: https://wordpress.com/read/feeds/35388914/posts/1024259222


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -