Android.Text.IInputFilter Implementation best approach

PulkitPulkit AUMember ✭✭

I would like to implement the above interface to have a custom Filter for my TextView/EditText. What would be the best way to do above in Xamarin. The implemented methods need me to return ICharSequence from one of the methods and IntPtr from another. Dont know how Xamarin uses them, and I have had crashes using ICharsequence, when .net VM is trying to access it in DVM

Posts

  • ChrisHonselaarChrisHonselaar NLBeta ✭✭✭

    Java.Lang.String implements ICharSequence, so you would probably work with that (or a C# string and convert that to Java.Lang.String).

  • PulkitPulkit AUMember ✭✭

    What about the Handle, what should I return for that

  • CheesebaronCheesebaron DKInsider, University mod

    If you are trying to implement IInputFilter you will need to inherit from Java.Lang.Object. This will help you implement the Handle.

    public class Filter : Java.Lang.Object, IInputFilter
    {
        public ICharSequence FilterFormatted(ICharSequence source, int start, int end, ISpanned dest, int dstart, int dend)
        {
            //Stuff
        }
    }
    
Sign In or Register to comment.