使用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中的组件一定要注意主题是否正确。


目录
相关文章
解决java.lang.IllegalStateException: Failed to load ApplicationContext错误~
解决java.lang.IllegalStateException: Failed to load ApplicationContext错误~
193 0
|
Java Docker 微服务
【Java异常】Caused by: java.lang.IllegalArgumentException: method GET must not have a request body
【Java异常】Caused by: java.lang.IllegalArgumentException: method GET must not have a request body
180 1
|
6月前
|
消息中间件
java.lang.RuntimeException: Only one Looper may be created per thread解决方法
java.lang.RuntimeException: Only one Looper may be created per thread解决方法
369 2
|
6月前
|
Java Spring
java.lang.Exception: Method a() should be public
java.lang.Exception: Method a() should be public
69 0
|
6月前
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
48 0
|
Java
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
145 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
135 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 异常
282 0
|
Java 数据库连接 Spring
java.lang.IllegalStateException: Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
下一篇
无影云桌面