summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.ControlGallery.Android/CustomRenderers.cs23
-rw-r--r--Xamarin.Forms.Maps.Android/MapRenderer.cs13
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/ViewRenderer.cs1
-rw-r--r--Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs6
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ProgressBarRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs8
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/SwitchRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TableViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.Android/ViewRenderer.cs2
24 files changed, 151 insertions, 28 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);
}
diff --git a/Xamarin.Forms.Maps.Android/MapRenderer.cs b/Xamarin.Forms.Maps.Android/MapRenderer.cs
index a0a3bbc1..29270c0b 100644
--- a/Xamarin.Forms.Maps.Android/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.Android/MapRenderer.cs
@@ -15,7 +15,7 @@ using System.Collections;
namespace Xamarin.Forms.Maps.Android
{
- public class MapRenderer : ViewRenderer,
+ public class MapRenderer : ViewRenderer<Map,MapView>,
GoogleMap.IOnCameraChangeListener
{
public MapRenderer ()
@@ -41,19 +41,24 @@ namespace Xamarin.Forms.Maps.Android
return new SizeRequest (new Size (Context.ToPixels (40), Context.ToPixels (40)));
}
- protected override void OnElementChanged (ElementChangedEventArgs<View> e)
+ protected override MapView CreateNativeControl()
+ {
+ return new MapView(Context);
+ }
+
+ protected override void OnElementChanged (ElementChangedEventArgs<Map> e)
{
base.OnElementChanged (e);
var oldMapView = (MapView)Control;
- var mapView = new MapView (Context);
+ var mapView = CreateNativeControl();
mapView.OnCreate (s_bundle);
mapView.OnResume ();
SetNativeControl (mapView);
if (e.OldElement != null) {
- var oldMapModel = (Map) e.OldElement;
+ var oldMapModel = e.OldElement;
((ObservableCollection<Pin>)oldMapModel.Pins).CollectionChanged -= OnCollectionChanged;
MessagingCenter.Unsubscribe<Map, MapSpan> (this, MoveMessageName);
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/ViewRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/ViewRenderer.cs
index 3c869216..85ff3985 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/ViewRenderer.cs
@@ -2,6 +2,5 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
{
public abstract class ViewRenderer<TView, TControl> : Android.ViewRenderer<TView, TControl> where TView : View where TControl : global::Android.Views.View
{
- protected abstract TControl CreateNativeControl();
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs b/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs
index 2036e4bb..d2f23978 100644
--- a/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/NativeViewWrapperRenderer.cs
@@ -17,6 +17,12 @@ namespace Xamarin.Forms.Platform.Android
return result ?? base.GetDesiredSize(widthConstraint, heightConstraint);
}
+ // not called by the view wrapper renderer
+ protected override global::Android.Views.View CreateNativeControl()
+ {
+ return new global::Android.Views.View(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<NativeViewWrapper> e)
{
base.OnElementChanged(e);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs
index 696e6f6d..f536b47e 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ActivityIndicatorRenderer.cs
@@ -13,6 +13,11 @@ namespace Xamarin.Forms.Platform.Android
AutoPackage = false;
}
+ protected override AProgressBar CreateNativeControl()
+ {
+ return new AProgressBar(Context) { Indeterminate = true };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<ActivityIndicator> e)
{
base.OnElementChanged(e);
@@ -20,7 +25,7 @@ namespace Xamarin.Forms.Platform.Android
AProgressBar progressBar = Control;
if (progressBar == null)
{
- progressBar = new AProgressBar(Context) { Indeterminate = true };
+ progressBar = CreateNativeControl();
SetNativeControl(progressBar);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
index 5de429af..4f384b3b 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ButtonRenderer.cs
@@ -80,6 +80,11 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override AButton CreateNativeControl()
+ {
+ return new AButton(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
{
base.OnElementChanged(e);
@@ -89,7 +94,7 @@ namespace Xamarin.Forms.Platform.Android
AButton button = Control;
if (button == null)
{
- button = new AButton(Context);
+ button = CreateNativeControl();
button.SetOnClickListener(ButtonClickListener.Instance.Value);
button.Tag = this;
SetNativeControl(button);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
index 73e5183f..96028c39 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
@@ -42,13 +42,18 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override EditText CreateNativeControl()
+ {
+ return new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var textField = new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ var textField = CreateNativeControl();
textField.SetOnClickListener(TextFieldClickHandler.Instance);
SetNativeControl(textField);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs
index 14078abc..c9b596bc 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EditorRenderer.cs
@@ -33,6 +33,11 @@ namespace Xamarin.Forms.Platform.Android
((IElementController)Element).SetValueFromRenderer(Editor.TextProperty, s.ToString());
}
+ protected override EditorEditText CreateNativeControl()
+ {
+ return new EditorEditText(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
@@ -42,7 +47,7 @@ namespace Xamarin.Forms.Platform.Android
EditorEditText edit = Control;
if (edit == null)
{
- edit = new EditorEditText(Context);
+ edit = CreateNativeControl();
SetNativeControl(edit);
edit.AddTextChangedListener(this);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs
index c1b0b5e3..c1c24a83 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs
@@ -49,6 +49,11 @@ namespace Xamarin.Forms.Platform.Android
((IElementController)Element).SetValueFromRenderer(Entry.TextProperty, s.ToString());
}
+ protected override EntryEditText CreateNativeControl()
+ {
+ return new EntryEditText(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
@@ -57,7 +62,7 @@ namespace Xamarin.Forms.Platform.Android
if (e.OldElement == null)
{
- _textView = new EntryEditText(Context);
+ _textView = CreateNativeControl();
_textView.ImeOptions = ImeAction.Done;
_textView.AddTextChangedListener(this);
_textView.SetOnEditorActionListener(this);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
index 1f8a7763..e3c68290 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ImageRenderer.cs
@@ -28,13 +28,18 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override AImageView CreateNativeControl()
+ {
+ return new FormsImageView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var view = new FormsImageView(Context);
+ var view = CreateNativeControl();
SetNativeControl(view);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
index 0be9740c..c544a239 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
@@ -67,12 +67,17 @@ namespace Xamarin.Forms.Platform.Android
return result;
}
+ protected override TextView CreateNativeControl()
+ {
+ return new FormsTextView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (_view == null)
{
- _view = new FormsTextView(Context);
+ _view = (FormsTextView)CreateNativeControl();
_labelTextColorDefault = _view.TextColors;
SetNativeControl(_view);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
index f8351923..1054e1e8 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs
@@ -95,6 +95,11 @@ namespace Xamarin.Forms.Platform.Android
_adapter.IsAttachedToWindow = _isAttached;
}
+ protected override AListView CreateNativeControl()
+ {
+ return new AListView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
@@ -116,7 +121,7 @@ namespace Xamarin.Forms.Platform.Android
if (nativeListView == null)
{
var ctx = Context;
- nativeListView = new AListView(ctx);
+ nativeListView = CreateNativeControl();
_refresh = new SwipeRefreshLayout(ctx);
_refresh.SetOnRefreshListener(this);
_refresh.AddView(nativeListView, LayoutParams.MatchParent);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
index 92a65117..c7e45ad9 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/NavigationMenuRenderer.cs
@@ -26,13 +26,18 @@ namespace Xamarin.Forms.Platform.Android
get { return Element as NavigationMenu; }
}
+ protected override AView CreateNativeControl()
+ {
+ return new GridView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<View> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var grid = new GridView(Context);
+ var grid = (GridView)CreateNativeControl();
grid.SetVerticalSpacing(20);
SetNativeControl(grid);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
index 0bddfb58..a97a208c 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/OpenGLViewRenderer.cs
@@ -28,6 +28,11 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override GLSurfaceView CreateNativeControl()
+ {
+ return new GLSurfaceView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<OpenGLView> e)
{
base.OnElementChanged(e);
@@ -40,7 +45,7 @@ namespace Xamarin.Forms.Platform.Android
GLSurfaceView surfaceView = Control;
if (surfaceView == null)
{
- surfaceView = new GLSurfaceView(Context);
+ surfaceView = CreateNativeControl();
surfaceView.SetEGLContextClientVersion(2);
SetNativeControl(surfaceView);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
index f2abe9d3..b6d81718 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/PickerRenderer.cs
@@ -36,6 +36,11 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override EditText CreateNativeControl()
+ {
+ return new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
if (e.OldElement != null)
@@ -46,7 +51,7 @@ namespace Xamarin.Forms.Platform.Android
((ObservableList<string>)e.NewElement.Items).CollectionChanged += RowsCollectionChanged;
if (Control == null)
{
- var textField = new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ var textField = CreateNativeControl();
textField.SetOnClickListener(PickerListener.Instance);
_textColorSwitcher = new TextColorSwitcher(textField.TextColors);
SetNativeControl(textField);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ProgressBarRenderer.cs
index 865732f7..63316a22 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ProgressBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ProgressBarRenderer.cs
@@ -10,13 +10,18 @@ namespace Xamarin.Forms.Platform.Android
AutoPackage = false;
}
+ protected override AProgressBar CreateNativeControl()
+ {
+ return new AProgressBar(Context, null, global::Android.Resource.Attribute.ProgressBarStyleHorizontal) { Indeterminate = false, Max = 10000 };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<ProgressBar> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var progressBar = new AProgressBar(Context, null, global::Android.Resource.Attribute.ProgressBarStyleHorizontal) { Indeterminate = false, Max = 10000 };
+ var progressBar = CreateNativeControl();
SetNativeControl(progressBar);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
index 5e498952..468710ca 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/SearchBarRenderer.cs
@@ -1,3 +1,4 @@
+using System;
using System.ComponentModel;
using System.Linq;
using Android.Content.Res;
@@ -36,6 +37,11 @@ namespace Xamarin.Forms.Platform.Android
return true;
}
+ protected override SearchView CreateNativeControl()
+ {
+ return new SearchView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
{
base.OnElementChanged(e);
@@ -46,7 +52,7 @@ namespace Xamarin.Forms.Platform.Android
if (searchView == null)
{
- searchView = new SearchView(Context);
+ searchView = CreateNativeControl();
searchView.SetIconifiedByDefault(false);
searchView.Iconified = false;
SetNativeControl(searchView);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
index dbe1887f..5df5bf31 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/SliderRenderer.cs
@@ -34,13 +34,18 @@ namespace Xamarin.Forms.Platform.Android
{
}
+ protected override SeekBar CreateNativeControl()
+ {
+ return new FormsSeekBar(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var seekBar = new FormsSeekBar(Context);
+ var seekBar = CreateNativeControl();
SetNativeControl(seekBar);
seekBar.Max = 1000;
diff --git a/Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs
index 70eed60b..88b5fd75 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs
@@ -16,6 +16,11 @@ namespace Xamarin.Forms.Platform.Android
AutoPackage = false;
}
+ protected override LinearLayout CreateNativeControl()
+ {
+ return new LinearLayout(Context) { Orientation = Orientation.Horizontal };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{
base.OnElementChanged(e);
@@ -31,7 +36,7 @@ namespace Xamarin.Forms.Platform.Android
_upButton.SetOnClickListener(StepperListener.Instance);
_upButton.SetHeight((int)Context.ToPixels(10.0));
- var layout = new LinearLayout(Context) { Orientation = Orientation.Horizontal };
+ var layout = CreateNativeControl();
layout.AddView(_downButton);
layout.AddView(_upButton);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/SwitchRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/SwitchRenderer.cs
index 39916b58..2c0b0144 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/SwitchRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/SwitchRenderer.cs
@@ -47,6 +47,11 @@ namespace Xamarin.Forms.Platform.Android
base.Dispose(disposing);
}
+ protected override ASwitch CreateNativeControl()
+ {
+ return new ASwitch(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
{
base.OnElementChanged(e);
@@ -58,7 +63,7 @@ namespace Xamarin.Forms.Platform.Android
{
if (Control == null)
{
- var aswitch = new ASwitch(Context);
+ var aswitch = CreateNativeControl();
aswitch.SetOnCheckedChangeListener(this);
SetNativeControl(aswitch);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TableViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TableViewRenderer.cs
index e4017a7e..2ac8efa6 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TableViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TableViewRenderer.cs
@@ -21,6 +21,11 @@ namespace Xamarin.Forms.Platform.Android
return new Size(40, 40);
}
+ protected override AListView CreateNativeControl()
+ {
+ return new AListView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<TableView> e)
{
base.OnElementChanged(e);
@@ -28,7 +33,7 @@ namespace Xamarin.Forms.Platform.Android
AListView listView = Control;
if (listView == null)
{
- listView = new AListView(Context);
+ listView = CreateNativeControl();
SetNativeControl(listView);
}
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
index 2b33acc6..2bd60a7d 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
@@ -34,13 +34,18 @@ namespace Xamarin.Forms.Platform.Android
_dialog = null;
}
+ protected override EditText CreateNativeControl()
+ {
+ return new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
- var textField = new EditText(Context) { Focusable = false, Clickable = true, Tag = this };
+ var textField = CreateNativeControl();
textField.SetOnClickListener(TimePickerListener.Instance);
SetNativeControl(textField);
diff --git a/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
index 24a5af57..bd5b8059 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/WebViewRenderer.cs
@@ -56,13 +56,18 @@ namespace Xamarin.Forms.Platform.Android
return new Size(Context.ToPixels(40), Context.ToPixels(40));
}
+ protected override AWebView CreateNativeControl()
+ {
+ return new AWebView(Context);
+ }
+
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
- var webView = new AWebView(Context);
+ var webView = CreateNativeControl();
#pragma warning disable 618 // This can probably be replaced with LinearLayout(LayoutParams.MatchParent, LayoutParams.MatchParent); just need to test that theory
webView.LayoutParameters = new global::Android.Widget.AbsoluteLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent, 0, 0);
#pragma warning restore 618
diff --git a/Xamarin.Forms.Platform.Android/ViewRenderer.cs b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
index 63fef49c..f285d6d9 100644
--- a/Xamarin.Forms.Platform.Android/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/ViewRenderer.cs
@@ -13,6 +13,8 @@ namespace Xamarin.Forms.Platform.Android
public abstract class ViewRenderer<TView, TNativeView> : VisualElementRenderer<TView>, AView.IOnFocusChangeListener where TView : View where TNativeView : AView
{
+ protected abstract TNativeView CreateNativeControl();
+
ViewGroup _container;
bool _disposed;