diff options
author | Marcus Lum <marcusl@gmail.com> | 2016-08-30 13:37:07 -0400 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-30 10:37:07 -0700 |
commit | 61f34d113c9f6941194a6ed3101f54158de722a3 (patch) | |
tree | b6211a4e1a4dba6ec40aad3823a795387e851815 /Xamarin.Forms.ControlGallery.Android | |
parent | 5b85aafcd671f5e8745cf52339c20378f91cb748 (diff) | |
download | xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.tar.gz xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.tar.bz2 xamarin-forms-61f34d113c9f6941194a6ed3101f54158de722a3.zip |
Allow Custom Android MapRenderers to override the default MapView options (#285)
* Allow Custom Android MapRenderers to override the default MapView options
* Larger effort to use CreateNativeControl () everywhere instead of just in the Android AppCompat renderers.
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); } |