码迷,mamicode.com
首页 > 移动开发 > 详细

详细解读Android中的搜索框(四)—— Searchable配置文件

时间:2015-01-15 18:05:20      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

 <?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: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>

一、 通用属性

1. label="string resource"

【必选】它应该和你的程序的名字一样。只有android:includeInGlobalSearch为"true"时,它才多用户可见。它就是在search settings的searchable列表中所用的名字。
 
2. hint
建议包含该属性。它是用户在输入框键入字符之前,在输入框显示的字符。为个和别的应用程序一致,它应该为搜索xx,比如"Search songs and artists" or "Search YouTube"

3. searchMode

技术分享

搜索模式。它表示当用户选择了一个suggestion(提示建议)后,以何种方式重写输入框中的搜索关键字。如果设置该属性,则不会进行输入框内搜索关键字的重写。

如果设置该属性,则有两种模式可以选:
queryRewriteFromText:用suggestion Cursor的SUGGEST_COLUMN_TEXT_1列的内容进行重写。
queryRewriteFromData:这样suggestion Cursor的SUGGEST_COLUMN_INTENT_DATA列将用于改写query text。但是这时SUGGEST_COLUMN_INTENT_DATA的值必须是对用户可见的URI(比如http形式)或其他格式,不能使用内部的URI。
 
4. searchButtonText
搜索按钮的文本。默认的是搜索按钮显示的是个搜索图标。如果你的搜索行为是普遍的搜索行为,请不要改变它,即不要设置该属性。
 
5. inputType
输入的类型。对于大多数搜索应该,都是输入文本来进行搜索,所以一般你不需要设置该属性。

 

 

关于更多属性请参考:

http://blog.csdn.net/hudashi/article/details/7055959

http://blog.csdn.net/imdxt1986/article/details/7311968

 

详细解读Android中的搜索框(四)—— Searchable配置文件

标签:

原文地址:http://www.cnblogs.com/tianzhijiexian/p/4226720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!