diff options
Diffstat (limited to 'Xamarin.Forms.ControlGallery.Android')
-rw-r--r-- | Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs b/Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs index 1faa7a98..7f86a85d 100644 --- a/Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs +++ b/Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs @@ -97,13 +97,18 @@ namespace Xamarin.Forms.ControlGallery.Android { } + protected override global::Android.Widget.ListView CreateNativeControl() + { + return new global::Android.Widget.ListView(Forms.Context); + } + protected override void OnElementChanged(ElementChangedEventArgs<NativeListView> e) { base.OnElementChanged(e); if (Control == null) { - SetNativeControl(new global::Android.Widget.ListView(Forms.Context)); + SetNativeControl(CreateNativeControl()); } if (e.OldElement != null) @@ -266,13 +271,18 @@ namespace Xamarin.Forms.ControlGallery.Android { } + protected override global::Android.Widget.ListView CreateNativeControl() + { + return new global::Android.Widget.ListView(Forms.Context); + } + protected override void OnElementChanged(ElementChangedEventArgs<NativeListView2> e) { base.OnElementChanged(e); if (Control == null) { - SetNativeControl(new global::Android.Widget.ListView(Forms.Context)); + SetNativeControl(CreateNativeControl()); } if (e.OldElement != null) @@ -406,7 +416,7 @@ namespace Xamarin.Forms.ControlGallery.Android return view; } } - public class CustomContentRenderer : ViewRenderer + public abstract class CustomContentRenderer : ViewRenderer { } @@ -435,11 +445,16 @@ namespace Xamarin.Forms.ControlGallery.Android public class CustomButtonRenderer : ButtonRenderer { + protected override AButton CreateNativeControl() + { + return new CustomNativeButton(Context); + } + protected override void OnElementChanged(ElementChangedEventArgs<Button> e) { if (Control == null) { - CustomNativeButton b = new CustomNativeButton(Context); + CustomNativeButton b = (CustomNativeButton)CreateNativeControl(); SetNativeControl(b); } |