protected override void OnElementChanged(ElementChangedEventArgs <DropDownPicker> e) { base.OnElementChanged(e); if (this.Control == null) { var inflater = (global::Android.Views.LayoutInflater)Xamarin.Forms.Forms.Context.GetSystemService(global::Android.App.Service.LayoutInflaterService); var layout = inflater.Inflate(Resource.Layout.spinner, null).JavaCast <LinearLayout> (); this._SpinnerControl = layout.FindViewById <MyAppCompatSpinner> (Resource.Id.spinner2); this._SpinnerControl.FormsElement = this.Element; this._SpinnerControl.OnItemSelectedListener = this; this._SpinnerControl.LayoutChange += SpinnerLayoutChange; SetAdapter(); this._Adapter.SelectedText = Element.SelectedText; this._SpinnerControl.Adapter = this._Adapter; this._SpinnerControl.Clickable = true; this._SpinnerControl.OnItemSelectedListener = this; this.SetNativeControl(layout); DropDownPicker.OnMessageTo += AddMessageTO; } }
protected override void Dispose(bool disposing) { if (this._Adapter != null) { this._Adapter.Dispose(); } DropDownPicker.OnMessageTo -= AddMessageTO; this._SpinnerControl.LayoutChange -= SpinnerLayoutChange; this._SpinnerControl.Dispose(); this._SpinnerControl = null; base.Dispose(disposing); }
protected override void OnElementChanged(ElementChangedEventArgs <DropDownPicker> e) { base.OnElementChanged(e); if (this.Control == null) { var inflater = (global::Android.Views.LayoutInflater)Xamarin.Forms.Forms.Context.GetSystemService(global::Android.App.Service.LayoutInflaterService); var layout = inflater.Inflate(Resource.Layout.spinner, null).JavaCast <LinearLayout> (); var parentl = layout.FindViewById <LinearLayout> (Resource.Id.parentLayoutSpinner); // spinner border color. parentl.Background = RectBorder(this.Element.BorderColor.ToAndroid(), 5); this._SpinnerControl = layout.FindViewById <MyAppCompatSpinner> (Resource.Id.spinner2); this._SpinnerControl.FormsElement = this.Element; this._SpinnerControl.OnItemSelectedListener = this; this._SpinnerControl.LayoutChange += SpinnerLayoutChange; // spinner arrow color Drawable spinnerDrawable = _SpinnerControl.Background.GetConstantState().NewDrawable(); spinnerDrawable.SetColorFilter(this.Element.ArrowColor.ToAndroid(), PorterDuff.Mode.SrcAtop); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) { _SpinnerControl.SetBackground(spinnerDrawable); } else { _SpinnerControl.SetBackgroundDrawable(spinnerDrawable); } SetAdapter(); this._Adapter.SelectedText = Element.SelectedText; this._SpinnerControl.Adapter = this._Adapter; this._SpinnerControl.Clickable = true; this._SpinnerControl.OnItemSelectedListener = this; this.SetNativeControl(layout); DropDownPicker.OnMessageTo += AddMessageTO; } }