作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
查看我的日志
Java.Lang.NoSuchMethodError: no non-static method "Landroid/content/Context;.getColorStateList(I)Landroid/content/res/ColorStateList;"
01-11 12:48:49.249 I/MonoDroid( 9688): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <fcbf47a04b2e4d90beafbae627e1fca4>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Java.Interop.JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature) [0x0005b] in <3cb12bce834a498199b2be6cd3e00922>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Java.Interop.JniType.GetInstanceMethod (System.String name, System.String signature) [0x0000c] in <3cb12bce834a498199b2be6cd3e00922>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Java.Interop.JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember) [0x00031] in <3cb12bce834a498199b2be6cd3e00922>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00006] in <3cb12bce834a498199b2be6cd3e00922>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Android.Content.Context.GetColorStateList (System.Int32 id) [0x00022] in <551e90b840814b76a3d15b7bbaa8a77c>:0
01-11 12:48:49.249 I/MonoDroid( 9688): at Movo.MapActivity+<OnCreate>d__37.MoveNext () [0x000a6] in C:\Users\MapActivity.cs:85 An unhandled exception occured.
最佳答案
基于上下文的GetColorStateList
在 API 级别 23 中添加,因此如果您尝试在较旧的 Android 版本上执行该方法,它将失败。
现在,在 com.android.support:support-compat
(版本 24.1+)(通过 Xamarin Nuget Xamarin.Android.Support.Compat),有一个基于 ContextCompat 的 GetColorStateList
可用于较旧(和较新)的 API 级别
关于android - Java.Lang.NoSuchMethodError : No non-static method "Landroid/content/Context;.getColorStateList(I)Landroid/content/res/ColorStateList;" 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54142052/
我是一名优秀的程序员,十分优秀!