Beispiel #1
0
        private ImageView CreateIcon(SwipeMenuItem item)
        {
            ImageView iv = new ImageView(Context);

            iv.SetImageDrawable(item.Icon);
            return(iv);
        }
Beispiel #2
0
        private TextView CreateTitle(SwipeMenuItem item)
        {
            TextView tv = new TextView(Context);

            tv.Text     = item.Title;
            tv.Gravity  = GravityFlags.Center;
            tv.TextSize = item.TitleSize;
            tv.SetTextColor(item.TitleColor);
            return(tv);
        }
        public void Create(SwipeMenu menu)
        {
            SwipeMenuItem openItem = new SwipeMenuItem(MainActivity.mainActivity);

            openItem.Background = new ColorDrawable(Android.Graphics.Color.Green);
            openItem.Title      = "打开";
            openItem.TitleSize  = 20;
            openItem.Width      = 100;
            openItem.TitleColor = Android.Graphics.Color.White;

            SwipeMenuItem deleteItem = new SwipeMenuItem(MainActivity.mainActivity);

            deleteItem.Background = new ColorDrawable(Android.Graphics.Color.Gray);
            deleteItem.Title      = "删除";
            deleteItem.TitleSize  = 20;
            deleteItem.Width      = 100;
            deleteItem.TitleColor = Android.Graphics.Color.Black;

            menu.AddMenuItem(openItem);
            menu.AddMenuItem(deleteItem);
        }
Beispiel #4
0
        private void AddItem(SwipeMenuItem item, int id)
        {
            LayoutParams param  = new LayoutParams(item.Width, LayoutParams.MatchParent);
            LinearLayout parent = new LinearLayout(Context);

            parent.Id = id;
            parent.SetGravity(GravityFlags.Center);
            parent.Orientation      = global::Android.Widget.Orientation.Vertical;
            parent.LayoutParameters = param;
            parent.SetBackgroundDrawable(item.Background);
            parent.SetOnClickListener(this);
            AddView(parent);

            if (item.Icon != null)
            {
                parent.AddView(CreateIcon(item));
            }

            if (!String.IsNullOrEmpty(item.Title))
            {
                parent.AddView(CreateTitle(item));
            }
        }
Beispiel #5
0
 public void RemoveMenuItem(SwipeMenuItem item)
 {
     mItems.Remove(item);
 }
Beispiel #6
0
 public void AddMenuItem(SwipeMenuItem item)
 {
     mItems.Add(item);
 }