Skip to content

Instantly share code, notes, and snippets.

@InnovativeTechies
Created July 8, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InnovativeTechies/3495d129d46a27a7ccfd209563abfeb8 to your computer and use it in GitHub Desktop.
Save InnovativeTechies/3495d129d46a27a7ccfd209563abfeb8 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
using Android.Support.V7.App;
using Android.Text;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using MaterialTextField;
using MaterialTextField.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(EntryView), typeof(EntryViewRenderer))]
namespace MaterialTextField.Droid
{
public class EntryViewRenderer : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<EntryView, TextInputLayout>
{
global::Android.Views.View view;
EntryView entryView;
TextInputEditText editText;
Activity activity;
public EntryViewRenderer(Context ctx) : base(ctx)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<EntryView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
entryView = e.NewElement as EntryView;
}
if (e.OldElement != null || Element == null)
{
return;
}
try
{
SetupUserInterface();
//SetupEventHandlers();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(@"ERROR: ", ex.Message);
}
}
void SetupUserInterface()
{
activity = this.Context as Activity;
var layout = (TextInputLayout)LayoutInflater.From(Context).Inflate(Resource.Layout.MaterialEntryLayout, null);
editText = layout.FindViewById<TextInputEditText>(Resource.Id.editText1);
layout.CounterEnabled = true;
layout.CounterMaxLength = 5;
SetNativeControl(layout);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment