WEB开发网
开发学院手机开发Android 开发 android利用数据库实现搜索联想功能 阅读

android利用数据库实现搜索联想功能

 2010-05-26 02:13:00 来源:WEB开发网   
核心提示:for (SearchUtil.Word word : words) {cursor.addRow(columnValuesOfWord(id++, word));}return cursor;}private Object[] columnValuesOfWord(long id, SearchUtil.Word w

for (SearchUtil.Word word : words) {

cursor.addRow(columnValuesOfWord(id++, word));

}

return cursor;

}

private Object[] columnValuesOfWord(long id, SearchUtil.Word word) {

return new Object[] { id, // _id

word.word, // text1

word.definition, // text2

word.word, // intent_data (included when clicking on item)

};

}

private static final String[] COLUMNS = { "_id",

SearchManager.SUGGEST_COLUMN_TEXT_1,

SearchManager.SUGGEST_COLUMN_TEXT_2,

SearchManager.SUGGEST_COLUMN_INTENT_DATA,// 数据传递到intenter中

};

@Override

public int update(Uri uri, ContentValues values, String selection,

String[] selectionArgs) {

return 0;

}

相关搜索的配置:

< application android:icon="@drawable/icon" android:label="@string/app_name" >

< activity android:name=".SearchActivty" android:label="@string/app_name" >

< intent-filter >

< action android:name="android.intent.action.MAIN" / >

< category android:name="android.intent.category.LAUNCHER" / >

< /intent-filter >

< 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" / >

< /activity >

< activity android:name=".ResultActivty" android:label="@string/search_query_results" >

< /activity >

< provider android:name="SearchProvider"

android:authorities="search"

android:syncable="false" / >

< /application >

Tags:android 利用 数据库

编辑录入:coldstar [复制链接] [打 印]
赞助商链接