现在的位置: 首页 > 综合 > 正文

【Android】使用SearchView时软键盘不支持actionSearch的问题

2012年12月02日 ⁄ 综合 ⁄ 共 681字 ⁄ 字号 评论关闭

前言

变态问题常有,今年特别多,,, - - # 今天遇到的这个非处理不可,不然没法在HTC One S使用SearchView,其软键盘不支持action设置。

 

 声明

  欢迎转载,但请保留文章原始出处:)

    博客园:http://www.cnblogs.com

    农民伯伯: http://www.cnblogs.com/over140/ 

 

正文

问题设备:

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
=" ? " />

解决办法:

SearchView有一个setSubmitButtonEnabled方法,设置为true即可,搜索框不为空就会显示。效果如下图:

 

 在onCreateOptionsMenu中inflate后调用,记得判断API Level。

抱歉!评论已关闭.