问题设备:
HTC One S
searchable.xml
<
searchable
xmlns:android
="http://schemas.android.com/apk/res/android"
android:label ="@string/search_label"
android:hint ="@string/search_hint"
android:voiceSearchMode ="showVoiceSearchButton|launchRecognizer"
android:imeOptions ="actionSearch"
android:searchSuggestAuthority ="com.xxx.provider.searchsuggestion"
android:searchSuggestSelection =" ? " />
android:label ="@string/search_label"
android:hint ="@string/search_hint"
android:voiceSearchMode ="showVoiceSearchButton|launchRecognizer"
android:imeOptions ="actionSearch"
android:searchSuggestAuthority ="com.xxx.provider.searchsuggestion"
android:searchSuggestSelection =" ? " />
解决办法:
SearchView有一个setSubmitButtonEnabled方法,设置为true即可,搜索框不为空就会显示。效果如下图:
在onCreateOptionsMenu中inflate后调用,记得判断API Level。
本文转自博客园农民伯伯的博客,原文链接:【Android】使用SearchView时软键盘不支持actionSearch的问题,如需转载请自行联系原博主。