public static Android.Widget.FrameLayout AddViewOnFrameLayout(Android.Views.View view, int width, int height) { var layout = new Android.Widget.FrameLayout(view.Context); layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); view.LayoutParameters = new Android.Widget.FrameLayout.LayoutParams(width, height); layout.AddView(view); return(layout); }
void CreateDialog() { if (_TextPickerCell.Items == null || _TextPickerCell.Items.Count == 0) { return; } var displayValues = _TextPickerCell.Items.Cast <object>().Select(x => x.ToString()).ToArray(); _picker = new APicker(_context); _picker.DescendantFocusability = DescendantFocusability.BlockDescendants; _picker.MinValue = 0; _picker.MaxValue = _TextPickerCell.Items.Count - 1; _picker.SetDisplayedValues(displayValues); _picker.Value = Math.Max(_TextPickerCell.Items.IndexOf(_TextPickerCell.SelectedItem), 0); _picker.WrapSelectorWheel = _TextPickerCell.IsCircularPicker; if (_dialog == null) { using (var builder = new AlertDialog.Builder(_context)) { builder.SetTitle(_title); Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context); parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, GravityFlags.Center)); builder.SetView(parent); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { ClearFocus(); }); builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => { _TextPickerCell.SelectedItem = _TextPickerCell.Items[_picker.Value]; _command?.Execute(_TextPickerCell.Items[_picker.Value]); ClearFocus(); }); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.DismissEvent += (ss, ee) => { _dialog.Dispose(); _dialog = null; _picker.RemoveFromParent(); _picker.Dispose(); _picker = null; }; _dialog.Show(); } }
void CreateDialog() { _picker = new APicker(_context); _picker.MinValue = _min; _picker.MaxValue = _max; _picker.Value = _NumberPikcerCell.Number; if (_dialog == null) { using (var builder = new AlertDialog.Builder(_context)) { builder.SetTitle(_title); Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context); parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, GravityFlags.Center)); builder.SetView(parent); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { ClearFocus(); }); builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => { _NumberPikcerCell.Number = _picker.Value; _command?.Execute(_picker.Value); ClearFocus(); }); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.DismissEvent += (ss, ee) => { _dialog.Dispose(); _dialog = null; _picker.RemoveFromParent(); _picker.Dispose(); _picker = null; }; _dialog.Show(); } }
void CreateDialog() { if (_dialog != null) { return; } var picker = new APicker(_view.Context); picker.MinValue = _min; picker.MaxValue = _max; picker.Value = _number; using (var builder = new AlertDialog.Builder(_view.Context)) { builder.SetTitle(AddNumberPicker.GetTitle(Element)); Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_view.Context); parent.AddView(picker, new Android.Widget.FrameLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, GravityFlags.Center)); builder.SetView(parent); builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { }); builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => { AddNumberPicker.SetNumber(Element, picker.Value); _command?.Execute(picker.Value); }); _dialog = builder.Create(); } _dialog.SetCanceledOnTouchOutside(true); _dialog.DismissEvent += (ss, ee) => { _dialog.Dispose(); _dialog = null; picker.RemoveFromParent(); picker.Dispose(); picker = null; }; _dialog.Show(); }
public Android.Views.View GetNativeView(View element) { this.Element.Children.Add(element); Android.Views.View targetView = null; for (int i = 0; i < ViewGroup.ChildCount; i++) { var view = ViewGroup.GetChildAt(i); var property = view.GetType().GetProperty("Element"); if (property != null) { var elem = property.GetValue(view); if (elem == element) { targetView = view; break; } } } if (targetView == null) { return(null); } ((Android.Views.ViewGroup)targetView.Parent).RemoveView(targetView); var container = new Android.Widget.FrameLayout(this.Context); container.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); targetView.LayoutParameters = new Android.Widget.FrameLayout.LayoutParams(Utils.DpToPx((float)element.WidthRequest), Utils.DpToPx((float)element.HeightRequest)); container.AddView(targetView); return(container); }