`
java-mans
  • 浏览: 11457780 次
文章分类
社区版块
存档分类
最新评论

Searchable之六(Voice Search和Search Suggestions)

 
阅读更多
十三,语言搜索(Voice Search)<wbr style="line-height:25px"><div style="line-height:25px"> <div style="line-height:23px; font-size:13px"><span style="color:#003366; line-height:23px">你可以通过在你的searchable配置中添加android:voiceSearchMode属性来实现search dialog或widget语言功能的添加。</span></div> <div style="line-height:23px; font-size:13px"><span style="color:#003366; line-height:23px">这样就添加了一个用于启动voice prompt的语音搜索的按钮。一但用户完成了speaking, 这个transcribed search query将传送到你的searchable activity.</span></div> <div style="line-height:23px; font-size:13px; font-weight:bold">示例11如下:</div> <div style="line-height:23px; font-size:13px"> <div style="line-height:23px"><span style="color:#3366ff; line-height:23px">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span></div> <div style="line-height:23px"><span style="color:#3366ff; line-height:23px">&lt;searchable xmlns:android="http://schemas.android.com/apk/res/android"</span></div> <div style="line-height:23px"><span style="color:#3366ff; line-height:23px"> android:label="@string/search_label"</span></div> <div style="line-height:23px"><span style="color:#3366ff; line-height:23px"> android:hint="@string/search_hint"</span></div> <div style="line-height:23px"> <span style="color:#3366ff; line-height:23px"> </span><span style="color:#ff6600; line-height:23px">android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"</span><span style="color:#3366ff; line-height:23px">&gt;</span> </div> <div style="line-height:23px"><span style="color:#3366ff; line-height:23px">&lt;/searchable&gt;</span></div> </div> <div style="line-height:23px; font-size:13px"><span style="color:#003366; line-height:23px">第一值"showVoiceSearchButton"用于开启voice search, 第二个值“launchRecognizer,”说明了voice search button应该启动一个recognizer来把transcribed text传递给你的searchable activity.</span></div> <div style="line-height:23px; font-size:13px"><span style="color:#003366; line-height:23px">你还可以使用其他的一些属性来定义voice search的行为,比如语言和返回的最大结果数。</span></div> <div style="line-height:23px; font-size:13px"> <span style="color:#003366; line-height:23px">关于</span><span style="line-height:23px; color:rgb(0,51,102)">voice search的</span><span style="color:#003366; line-height:23px">更多属性请参照</span><span style="line-height:22px; font-size:14px"><a rel="nofollow" href="http://developer.android.com/guide/topics/search/searchable-config.html" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">Searchable Configuration</a></span> </div> <div style="line-height:23px; font-size:13px"> <span style="line-height:23px">注意</span>:<span style="color:#000080; line-height:23px">请仔细考虑是否要在你的程序中使用voice search.所有通过voice search按钮的搜索都是直接传送给了你的searchable activity,用户根本没有机会预览transcribed query。需要充分测试语言识别(voice recognition),以便它能识别用户在你的程序中提交的各种请求。</span> </div> <div style="line-height:23px; font-size:13px"><span style="color:#000080; line-height:23px"><br style="line-height:23px"></span></div> <div style="line-height:25px"><span style="line-height:25px"><span style="font-size:16px; line-height:28px">十四、Search Suggestions</span></span></div> <div style="line-height:25px"> <span style="font-size:13px; line-height:23px"></span> <div style="line-height:20px; color:rgb(0,51,102)">search dialog和the search widget都可以在Android system系统的帮助下,在用户搜索的时候,提供建议搜索词。</div> <div style="line-height:20px; color:rgb(0,51,102)">系统将管理suggestions列表并处理用户选中suggestion事件.</div> <div style="line-height:20px; color:rgb(0,51,102)">一般你可以提供以下两种建议搜索词:</div> <div style="line-height:20px"> <span style="line-height:23px">最近的搜索词</span><span style="color:#003366; line-height:23px">:</span> </div> <div style="line-height:20px"> <span style="color:#000080; line-height:23px">这些搜索词只是你以前的一些搜索关键词。更多的内容请参照</span><span style="line-height:23px"><a rel="nofollow" href="http://developer.android.com/guide/topics/search/adding-recent-query-suggestions.html" style="color:rgb(207,121,28); line-height:23px; text-decoration:none">Adding Recent Query Suggestions</a>.</span> </div> <div style="line-height:20px"><span style="line-height:22px; font-size:14px"><span style="line-height:20px; font-size:13px"><span style="line-height:23px">个性化搜索词:</span></span></span></div> <div style="line-height:23px"> <div style="line-height:23px"><span style="color:#000080; line-height:23px">这些search suggestions都来自于你自己的数据, 它帮助用户快速选择正确的拼写或他们要搜索的项.</span></div> <div style="line-height:23px"> <span style="line-height:23px">图三</span><span style="color:#000080; line-height:23px">就是来自于dictionary程序一个个性化suggestions的界面图—用户可以选择一个suggestion来很快的得到它的定义。更多内容请参照</span><a rel="nofollow" href="http://developer.android.com/guide/topics/search/adding-custom-suggestions.html" style="color:rgb(207,121,28); line-height:23px; text-decoration:none">Adding Custom Suggestions</a> </div> </div> <div style="line-height:23px"><span style="line-height:23px">图三:</span></div> <div style="line-height:23px"><span style="line-height:22px; font-size:14px"><img alt="Searchable之六(Voice Search和Search Suggestions) - hubingforever - 民主与科学" src="http://developer.android.com/images/search/search-suggest-custom.png" style="line-height:25px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; max-width:100%; margin-top:0px; margin-right:10px; margin-bottom:0px; margin-left:0px"></span></div> </div> </div> </wbr>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics