I'm working with Xamarin Studio 6.1.3 and trying the latest Xamarin Android Support Design library 25.3.1, my target is set to API 24 and min version is 19.
I have my Floating Action Button defined like this in my axml:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="@mipmap/check_in_icon"
android:layout_marginRight="30dp"
android:layout_marginBottom="30dp"
app:backgroundTint="@color/check_in" />
I want the background tint color to change programmatically, which I tried to do with the following code:
fab.BackgroundTintList = GetInProgressColor();
Where GetInProgressColor method is:
public ColorStateList GetInProgressColor()
{
ColorStateList csl = new ColorStateList(new int[][] { new int[0] }, new int[] { Color.ParseColor("#f43636") });
return csl;
}
But when my code calls the BackgroundTintList property at runtime I get the error:
Java.Lang.NoSuchMethodError: no method with name='setBackgroundTintList' signature='(Landroid/content/res/ColorStateList;)V' in class Landroid/view/View;
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/501e63ce/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x00068] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11240
at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000f] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:228
at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x0003a] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:94
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00023] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:25
at Android.Views.View.set_BackgroundTintList (Android.Content.Res.ColorStateList value) [0x0002c] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.View.cs:4324
at QAbogados.Droid.Activities.AssigmentsActivity.SetInProgressStatus () [0x00043] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Activities/AssigmentsActivity.cs:391
at QAbogados.Droid.Presenters.AssignmentPresenter.SetCurrentAssignmentLifecycle (System.String currentLifecycle) [0x00072] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Presenters/AssignmentPresenter.cs:85
at QAbogados.Droid.Presenters.AssignmentPresenter+<GetAssignment>c__AnonStorey0.<>m__0 () [0x00066] in /Users/enapsys/Documents/QAbogados/git/QAbogados/UI/Droid/Presenters/AssignmentPresenter.cs:50
at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.IRunnable.cs:81
at at (wrapper dynamic-method) System.Object:baf8fb03-caca-4702-aa94-6d110a79963c (intptr,intptr)
at java.lang.NoSuchMethodError: no method with name='setBackgroundTintList' signature='(Landroid/content/res/ColorStateList;)V' in class Landroid/view/View;
at at mono.java.lang.RunnableImplementor.n_run(Native Method)
at at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at at android.os.Handler.handleCallback(Handler.java:733)
at at android.os.Handler.dispatchMessage(Handler.java:95)
at at android.os.Looper.loop(Looper.java:136)
at at android.app.ActivityThread.main(ActivityThread.java:5057)
at at java.lang.reflect.Method.invokeNative(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:515)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at at dalvik.system.NativeStart.main(Native Method)
Why is throwing this error? I should be able to modify the background tint color since I'm using the Design Support Library, I'm able to display the Floating Action Button so I should be able modify it's properties, or is there a different way to manipulate its properties at runtime?