调用android system Search UI须注意的问题

    技术2026-05-23  9

    想必在网上已经有很多文章已经写如何调用android 系统自带的 Search UI了,比如:http://407827531.javaeye.com/blog/663872#comments 但我在这里想和大家分享的是在call Search UI是必须注意的问题。

    1,String Resource

            <?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="string resource" android:hint="string resource" android:searchMode=["queryRewriteFromData" | "queryRewriteFromText"] android:searchButtonText="string resource" android:inputType="inputType" android:imeOptions="imeOptions" android:searchSuggestAuthority="string" android:searchSuggestPath="string" android:searchSuggestSelection="string" android:searchSuggestIntentAction="string" android:searchSuggestIntentData="string" android:searchSuggestThreshold="int" android:includeInGlobalSearch=["true" | "false"] android:searchSettingsDescription="string resource" android:queryAfterZeroResults=["true" | "false"] android:voiceSearchMode=["showVoiceSearchButton" | "launchWebSearch" | "launchRecognizer"] android:voiceLanguageModel=["free-form" | "web_search"] android:voicePromptText="string resource" android:voiceLanguage="string" android:voiceMaxResults="int" > <actionkey android:keycode="KEYCODE" android:queryActionMsg="string" android:suggestActionMsg="string" android:suggestActionMsgColumn="string" > </searchable> 

    这里面必须注意到android:label,android:hint,android:voicePromptText必须用String resource也就是必须引用String.xml里面的string,而不能直接用String,不然你是怎么调试都无法把Serach UI 调出来。(我曾经犯了这样的错,折腾了很久!)

     

    2,版本问题

    android 1.5和android 2.2版本的search UI的界面是不一样的。

     

    3,若你想把query string和data传递给search activity,你可以用startSearch带过去。若你不要可以直接呼叫onSearchRequested或者startSearch将对应的参数设置为空。

     

     

    最新回复(0)