如何把SearchManager和User Dictionary联系在一起?
先了解一下Search
1) In your <activity>
, an intent filter, and a reference to a searchable.xml
file (described below):
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
2) A content provider that can provide search suggestions according to the URIs and column formats specified by the Search Suggestions section of the SearchManager docs:
<!-- Provides search suggestions for words and their definitions. -->
<provider android:name="DictionaryProvider"
android:authorities="dictionary"
android:syncable="false" />
In the searchable.xml
file, you specify a few things about how you want the search system to present search for your app, including the authority of the content provider that provides suggestions for the user as they type. Here's an example of the searchable.xml
of an Android app that provides search suggestions within its own activities:
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:searchSuggestAuthority="dictionary"
android:searchSuggestIntentAction="android.intent.action.VIEW">
</searchable>
Note that the android:searchSuggestAuthority
attribute refers to the authority of the content provider we declared in AndroidManifest.xml
.
为了让search的范围可以包含dictionary,我们需要做:
- Implement a search interface using Android's search framework
- Provide custom search suggestions and offer them in Quick Search Box
- Create an SQLite database and an FTS3 table for full-text searches
-
Create a content provider to perform all search and suggestion queries
-
Use SimpleCursorAdapter to bind data from a Cursor to a ListView.
Note: For the original version of Searchable Dictionary,
which reads words from a file instead of a database and uses a custom BaseAdapter
,
see the SDK samples included with the platforms for API Level 4-6.
事实上,search framework 并没有提供搜索用户添加的数据的API,为了达到我们的目的,
必须使用支持我们的数据相关的API。怎么说呢?比如说,数据存在SQLite database,那么,
就应该使用android.database.sqlite APIs 来完成 searches 。
分享到:
相关推荐
浮Android项目动搜索框(SearchManager).rar
android浮动搜索框(SearchManager)
适合学习Android的同学和基于毕业生学习和参考,Android studio、idea、eclipse可以运行,建议使用Android studio或者idea
浮动搜索框(SearchManager).zip
Android---浮动搜索框(SearchManager)(An-Beer工作室)借鉴.pdf
谷歌搜索管理器插件是一款在谷歌浏览器上运行的准们用于进行搜索的插件,本站提供的是该插件的最新版,需要的朋友可以前来本站下载。 插件介绍 谷歌搜索管理器插件是一款可以让您轻松地从新标签页直接在搜索引擎...
浮动搜索框(SearchManager).doc.zip
Andorid项目源码 浮动搜索框(SearchManager)
这里是计算机专业-Andorid项目源码100套之一的浮动搜索框(SearchManager),希望能对大家有所帮助哦!
安卓app开发项目-浮动搜索框(SearchManager)(源码).zip
浮动搜索框(SearchManager)毕业设计—(包含完整源码可运行).zip