Exemple #1
0
        void CreateSkillsList()
        {
            LinearLayout l = FindViewById <LinearLayout>(Resource.Id.skillsLinearLayout);

            l.RemoveAllViews();

            foreach (SkillValue v in EditMonster.SkillValueList)
            {
                LinearLayout row = new LinearLayout(this);
                row.Orientation = Orientation.Horizontal;
                row.SetBackgroundColor(new Android.Graphics.Color(0xff, 0xff, 0xff));
                row.SetPadding(1, 2, 1, 2);

                TextView t = new TextView(this);
                t.Text = v.Name;
                t.SetTextSize(Android.Util.ComplexUnitType.Dip, 18);
                //t.SetBackgroundColor(new Android.Graphics.Color(0xff, 0x33, 0x33));
                t.SetMinimumWidth(130);


                row.AddView(t);
                if (Monster.SkillsDetails[v.Name].Subtypes != null)
                {
                    EditText et = new EditText(this);
                    et.Text             = v.Subtype;
                    et.LayoutParameters = new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.FillParent,
                        ViewGroup.LayoutParams.MatchParent, 1f);
                    row.AddView(et);
                }
                else
                {
                    t.LayoutParameters = new LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.FillParent,
                        ViewGroup.LayoutParams.MatchParent, 1f);
                }

                SkillValue s = v;


                EditText mod = new EditText(this);
                mod.MakeNumber();
                mod.Text = v.Mod.ToString();
                row.AddView(mod);
                mod.SetMinimumWidth(60);
                mod.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) =>

                {
                    HandleModChanged((EditText)sender, s);
                };


                ImageButton b = new ImageButton(this);
                b.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.redx));

                row.AddView(b);
                b.Tag    = v.FullName;
                b.Click += (object sender, EventArgs e) =>
                {
                    AlertDialog.Builder bui = new AlertDialog.Builder(this);
                    bui.SetMessage("Remove skill?");
                    bui.SetPositiveButton("Yes", (a, x) => {
                        EditMonster.SkillValueDictionary.Remove(s.FullName);
                        EditMonster.UpdateSkillValueList();
                        CreateSkillsList();
                    });
                    bui.SetNegativeButton("No", (a, x) => {});
                    bui.Show();
                };


                l.AddView(row);
            }
        }