SingleChoiceItems AlertDialog

BlackShawarnaBlackShawarna ✭✭ITUniversity ✭✭

Hi all!

i've got an alert dialog with a list, all i want to do is, when an item is clicked save the item but i'm running in a problem

string[] the_array = tmp.OrderBy (q => q).ToArray ();

AlertDialog.Builder builderSingle = new AlertDialog.Builder (this);
            builderSingle.SetIcon (Resource.Drawable.menu_table);
            builderSingle.SetTitle ("Select");
            builderSingle.SetSingleChoiceItems (the_array, 0, new myDialogClickListener(the_array) );

            builderSingle.SetNegativeButton ("Delete", (senderAlert, args) =>  { Finish(); });
            builderSingle.SetPositiveButton ("Change Table", (senderAlert, args) => {

            //See if an item has been clicked
                if (Variables.selectedTableText == "") {
                    return;
                }

                string cat = selectedTableText.Split('/')[0];
                string number = selectedTableText.Split('/')[1];

            //...
                }

                Toast.MakeText (this, "Success", ToastLength.Short).Show ();
                Finish();
            });


            RunOnUiThread (() => {
                builderSingle.Show();
            } );

public class myDialogClickListener : IDialogInterfaceOnClickListener
        {
            string[] myArray;

            public myDialogClickListener (string[] a)
            {
                myArray = a;
            }

            void IDialogInterfaceOnClickListener.OnClick (IDialogInterface dialog, int which)
            {
                Variables.selectedTableText = myArray[which];
            }

            void IDisposable.Dispose ()
            {
                throw new NotImplementedException ();
            }

            IntPtr IJavaObject.Handle {
                get {
                    throw new NotImplementedException ();
                }
            }
        }

The dialog shows up, but when i click an item it goes to the interface Handle method and crash.
What is an implementation of this method? Because on the web, nobody implements this method, only the OnClick, unfortunately i must implement the handle method otherwise the program can't build.

Best Answer

Answers

Sign In or Register to comment.