Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- popup = new PopupMenu(this, _showMore, GravityFlags.Top);
- popup.MenuInflater.Inflate(Resource.Menu.showMoreMenu, popup.Menu);
- if (!string.IsNullOrEmpty(someValue))
- {
- popup.Menu.FindItem(Resource.Id.ABC1).SetVisible(false);
- }
- popup.MenuItemClick += Popup_MenuItemClick;
- popup.Show();
- PopupWindow popupWindow = new PopupWindow(this); // inflet your layout or diynamic add view
- LayoutInflater inflater = (LayoutInflater)GetSystemService(Context.LayoutInflaterService);
- View view = inflater.Inflate(Resource.Layout.TestLayout, null, false);
- TextView abc1 = (TextView)view.FindViewById(Resource.Id.abc1);
- TextView abc2 = (TextView)view.FindViewById(Resource.Id.abc2);
- TextView abc3 = (TextView)view.FindViewById(Resource.Id.abc3);
- abc1.Click += abc1_Click;
- abc2.Click += abc2_Click;
- if (!string.IsNullOrEmpty(somecondition))
- {
- abc1.Visibility = ViewStates.Gone;
- }
- else
- {
- abc2.Visibility = ViewStates.Gone;
- }
- popupWindow.Focusable = (true);
- popupWindow.Width = (WindowManagerLayoutParams.WrapContent);
- popupWindow.Height = (WindowManagerLayoutParams.WrapContent);
- popupWindow.ContentView = (view);
- popupWindow.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
- /*
- //tried
- var tttt= (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, Resource.Dimension._15sdp, Resources.DisplayMetrics);
- //tried
- int test=(int)(Resource.Dimension._15sdp * Resources.DisplayMetrics.Density);
- //tried
- float scale = Resources.DisplayMetrics.Density;
- test= (int)(Resource.Dimension._15sdp * scale + 0.5f);
- //tried
- var dp = Resource.Dimension._15sdp;
- int pixel = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, dp, Resources.DisplayMetrics);
- */
- popupWindow.ShowAsDropDown(_showMore, -220, -570); <-- fixed offset which works for 3 options
Add Comment
Please, Sign In to add comment