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

How to set cursor color for Entry and Editor when targeting Android

$
0
0

Having just upgraded from XF 4.8 to 5.0, I've had to migrate to using AndroidX. As a result, the piece of code that is found in multiple locations when Googling that allows the cursor color for Xamarin.Forms Entry and Editor Views to be set dynamically no longer works.

Instead, that code (see below) now throws
Java.Lang.NoSuchFieldError: no "I" field "mCursorDrawableRes" in class "Landroid/widget/TextView;" or its superclasses

IntPtr IntPtrTextViewClass = JNIEnv.FindClass(typeof(TextView));
IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrTextViewClass, "mCursorDrawableRes", "I");

For iOS, Xamarin now provide a SetCursorColor method (see https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.platformconfiguration.iosspecific.entry.setcursorcolor?view=xamarin-forms ).

How can we dynamically set the cursor color for Entry and Editor on Android when using XF 5.0 ?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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