注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

民主与科学

独立之人格,自由之思想

 
 
 

日志

 
 

Searchable配置文件详解(下)  

2011-05-30 19:38:57|  分类: 开发专题 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
文章来源:http://developer.android.com/guide/topics/search/searchable-config.html
<actionkey>的一些属性
<actionkey>主要用于定义在键入搜索关键字时或suggestion被focus时,按下哪个键,系统将把什么ACTION_MSG携带ACTION_SEARCH intent发送到你的searchable activity
比如对于Contacts,我们可能希望在一个suggestion被focus的时候,按下设备上call键,就直接向与被focus中的suggesion所对于的人拨打电话。这里的intent会直接通过component名直接传到你的searchable activity.
并不是每个设备都实现了Android定义的所有键,当然也不是所有的键可以被override.比如home,当它被按下的,系统应该总是回到home界面。一定不要把任何要用于输入的键设置为action key.这就大大限制了可以做action key的键,一般如果没硬键盘,就只有call或menu键。还要注意的是action key一般不发现的,所以你不应该把他们作为核心用户功能来提供。
你必须设置android:keycode属性和其他的任一属性。
android:keycode
String. (必须) A key code from KeyEvent that represents the action key you wish to respond to (for example "KEYCODE_CALL"). This is added to the ACTION_SEARCH intent that is passed to your searchable activity. To examine the key code, use getIntExtra(SearchManager.ACTION_KEY). Not all keys are supported for a search action, as many of them are used for typing, navigation, or system functions.
它用于定义在键入搜索关键字时或suggestion被focus时,哪个键被按下,系统向你的searchable activity发送ACTION_SEARCH intent。
android:queryActionMsg
String. An action message to be sent if the action key is pressed while the user is entering query text. This is added to the ACTION_SEARCH intent that the system passes to your searchable activity. To examine the string, use getStringExtra(SearchManager.ACTION_MSG).
它用于定义在键入搜索关键字时,某个键被按下时,系统向你的searchable activity发送ACTION_SEARCH intent的附加信息,该信息可以通过getStringExtra(SearchManager.ACTION_MSG)来提取
android:suggestActionMsg
String. An action message to be sent if the action key is pressed while a suggestion is in focus. This is added to the intent that that the system passes to your searchable activity (using the action you've defined for the suggestion). To examine the string, use getStringExtra(SearchManager.ACTION_MSG). This should only be used if all your suggestions support this action key. If not all suggestions can handle the same action key, then you must instead use the following android:suggestActionMsgColumn attribute.
它用于定义某个suggestion被focus时,某个键被按下时,系统向你的searchable activity发送ACTION_SEARCH intent的附加信息,该信息可以通过getStringExtra(SearchManager.ACTION_MSG)来提取
android:suggestActionMsgColumn
    String. The name of the column in your content provider that defines the action message for this action key, which is to be sent if the user presses the action key while a suggestion is in focus. This attribute lets you control the action key on a suggestion-by-suggestion basis, because, instead of using the android:suggestActionMsg attribute to define the action message for all suggestions, each entry in your content provider provides its own action message. 
First, you must define a column in your content provider for each suggestion to provide an action message, then provide the name of that column in this attribute. The system looks at your suggestion cursor, using the string provided here to select your action message column, and then select the action message string from the Cursor. That string is added to the intent that the system passes to your searchable activity (using the action you've defined for suggestions). To examine the string, use getStringExtra(SearchManager.ACTION_MSG). If the data does not exist for the selected suggestion, the action key is ignored.
当某个suggestion被focus时,某个键被按下时,系统向你的searchable activity发送ACTION_SEARCH intent的附加信息,该属性定义了附加信息来源于suggestion Cursor的哪一列,该附加信息可以通getStringExtra(SearchManager.ACTION_MSG)来提取。
注意android:suggestActionMsgandroid:suggestActionMsgColumn好像同时使用,就只有后者才有意义
示例res/xml/searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
   
android:label="@string/search_label"
   
android:hint="@string/search_hint"
   
android:searchSuggestAuthority="dictionary"
   
android:searchSuggestIntentAction="android.intent.action.VIEW"
   
android:includeInGlobalSearch="true"
   
android:searchSettingsDescription="@string/settings_description" >
</searchable>
  评论这张
 
阅读(559)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017