使用SearchView报错java.lang.UnsupportedOperationException: Failed to resolve ...

简介: SearchView是appcompat-v7中的一个组件,能够更快的实现一些基本的功能但是在布局中使用android.support.v7.widget.SearchView,打开该页面会crash,查看错误是加载布局出问题了

SearchView是appcompat-v7中的一个组件,能够更快的实现一些基本的功能

但是在布局中使用android.support.v7.widget.SearchView,打开该页面会crash,查看错误是加载布局出问题了


android.view.InflateException: Binary XML file line #26: Binary XML file line #26: Error inflating class android.support.v7.widget.SearchView

....

Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0200cb a=-1}


检查发现代码都没有什么问题,经过一番搜索发现是application的主题theme的问题 想要使用android.support.v7.widget.SearchView,主题必须是AppCompat的主题,这与AppCompatActivity类似。 所以以后使用appcompat-v7中的组件一定要注意主题是否正确。


目录
相关文章
|
JavaScript 前端开发 Java
Java的checked exception有意义吗?
Java的checked exception有意义吗?
74 0
|
6月前
|
Java 数据库连接 数据库
Error:Internal error: (java.lang.NoClassDefFoundError) Could not initialize class com.intellij.util.
Error:Internal error: (java.lang.NoClassDefFoundError) Could not initialize class com.intellij.util.
|
7月前
|
Java Spring
java.lang.Exception: Method a() should be public
java.lang.Exception: Method a() should be public
78 0
|
Java
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
169 0
|
Java Spring
【Java异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters
【Java异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters
188 0
|
Java 测试技术
java.lang.IllegalStateException Unable to find a @SpringBootConfiguration代码报错
java.lang.IllegalStateException Unable to find a @SpringBootConfiguration代码报错
|
Java 测试技术
已解决 java.lang.Exception: No runnable methods 异常
已解决 java.lang.Exception: No runnable methods 异常
293 0
|
Java 测试技术
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration
112 0
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState(已解决)
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState(已解决)
|
Java Spring
java异常之-Caused by: java.lang.IllegalStateException: Method has too many Body parameters
java异常之-Caused by: java.lang.IllegalStateException: Method has too many Body parameters
331 0