Android Settings搜索功能编程模型总结

  1. 定义变量SEARCH_INDEX_DATA_PROVIDER,用来供Settings利用反射获取到相应的检索数据。
  2. 可根据不同的情况,分别实现getXmlResourcesToIndex, getRawDataToIndex, getNonIndexableKeys提供Indexable数据

SearchIndexableResource

 nonIndexableKeys(List<String>)

 SearchIndexableRaw

 SearchIndexableResource-->SearchIndexableData数据结构

属性

定义

context

The context for the data. Will usually allow retrieving some resources.

locale

The locale for the data

enabled

Tells if the data will be included into the search results. This is application specific

rank

The rank for the data. This is application specific

key

The key for the data. This is application specific. Should be unique per data as the data

should be able to be retrieved by the key.

userId

The UserID for the data (in a multi user context).

className

The class name associated with the data. Generally this is a Fragment class name forreferring where the data is coming from and for launching the associated Fragment for

displaying the data. This is used only when the data is provided "locally".

packageName

The package name for retrieving the icon associated with the data.

iconResId

The icon resource ID associated with the data

intentAction

The Intent action associated with the data. This is used when the{@link SearchIndexableData#className} is not relevant.

intentTargetPackage

The Intent target package associated with the data.

intentTargetClass

The Intent target class associated with the data.

xmlResId[SearchIndexableResource]

Resource ID of the associated {@link android.preference.PreferenceScreen} XML file.

SearchIndexableRaw

属性

定义

title

Title's raw data

summaryOn

Summary's raw data when the data is "ON"

summaryOff

Summary's raw data when the data is "OFF"

entries

Entries associated with the raw data (when the data can have several values)

keywords

Keywords' raw data

 

  

Indexing过程


版权声明:本文为qq_29017813原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。