【Android】使用SearchView時軟鍵盤不支持actionSearch的問題



前言

變態問題常有,今年特別多,,, - - # 今天遇到的這個非處理不可,不然沒法在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。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM