Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Avoiding Obsolete Default Constructor with Android Custom Renderers in 2.5

$
0
0

Can anyone explain how to avoid the obsolete default constructor for android custom renderers in xamarin forms 2.5?

An example of a custom renderer from 2.4

[assembly: ExportRenderer(typeof(AutoCompleteEntry), typeof(AutoCompleteEntryRenderer))]
namespace MyApp.Droid
{
    public class AutoCompleteEntryRenderer : ViewRenderer<AutoCompleteEntry, AutoCompleteTextView>
    {
        protected override void OnElementChanged(ElementChangedEventArgs<AutoCompleteEntry> e) {
            base.OnElementChanged(e);

            if (e.OldElement == null && this.Element != null) {
                // Perform initialization
            }
        }
    }
}

However adding a new constructor that takes a Context does not work with the ExportRenderer attribute, it will throw an exception on run.

public AutoCompleteEntryRenderer(Context context)
    : base(context) {
}

Referencing Forms.Context is also obsolete so I'm just not sure how to get a context reference in 2.5


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>