Ejemplo n.º 1
0
        public static void AttachButtonStringPopover(String title, View t, List <String> options, string format, int startIndex, ActionClickedDelegate callback)
        {
            String text = "";

            if (startIndex >= 0)
            {
                t.Tag = options[startIndex];
            }
            if (t.Tag != null)
            {
                text = t.Tag.ToString();
            }

            if (t is TextView)
            {
                TextView tv = (TextView)t;
                tv.Text = String.Format(format, text);
            }
            t.Click += (object sender, EventArgs e) => {
                AlertDialog.Builder builderSingle = new AlertDialog.Builder(t.Context);

                builderSingle.SetTitle(title);
                ArrayAdapter <String> arrayAdapter = new ArrayAdapter <String>(t.Context,
                                                                               Android.Resource.Layout.SelectDialogItem);
                arrayAdapter.AddAll(options);


                builderSingle.SetAdapter(arrayAdapter, (se, ev) => {
                    string val = arrayAdapter.GetItem(ev.Which);
                    if (t is TextView)
                    {
                        TextView tv = (TextView)t;
                        tv.Text     = String.Format(format, val);
                    }
                    t.Tag = val;


                    if (callback != null)
                    {
                        callback(t, ev.Which, val);
                    }
                });


                builderSingle.Show();
            };
        }
Ejemplo n.º 2
0
        public static void AttachSimpleStringPopover(String title, View t, List <String> options, ActionClickedDelegate callback)
        {
            t.Click += (object sender, EventArgs e) => {
                AlertDialog.Builder builderSingle = new AlertDialog.Builder(t.Context);

                builderSingle.SetTitle(title);
                ArrayAdapter <String> arrayAdapter = new ArrayAdapter <String>(t.Context,
                                                                               Android.Resource.Layout.SelectDialogItem);
                arrayAdapter.AddAll(options);


                builderSingle.SetAdapter(arrayAdapter, (se, ev) => {
                    string val = arrayAdapter.GetItem(ev.Which);
                    t.Tag      = val;


                    if (callback != null)
                    {
                        callback(t, ev.Which, val);
                    }
                });


                builderSingle.Show();
            };
        }
Ejemplo n.º 3
0
 public static void AttachButtonStringPopover(String title, View t, List <String> options, int startIndex, ActionClickedDelegate callback)
 {
     AttachButtonStringPopover(title, t, options, "{0}", startIndex, callback);
 }