本文整理了Java中android.support.v7.widget.SearchView.setSuggestionsAdapter()
方法的一些代码示例,展示了SearchView.setSuggestionsAdapter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setSuggestionsAdapter()
方法的具体详情如下:
包路径:android.support.v7.widget.SearchView
类名称:SearchView
方法名:setSuggestionsAdapter
暂无
代码示例来源:origin: jtmcn/archwiki-viewer
private void setCursorAdapter(List<SearchResult> currentSuggestions) {
searchView.setSuggestionsAdapter(
SearchResultsAdapter.getCursorAdapter(this, currentSuggestions)
);
}
}
代码示例来源:origin: Phantast/smartnavi
public void handleMessage(Message msg) {
if (msg.what == 0) {
mSuggestionsAdapter = new SuggestionsAdapter(toolbar.getContext(), cursor);
searchView.setSuggestionsAdapter(GoogleMap.mSuggestionsAdapter);
// important to update suggestion list
searchView.getSuggestionsAdapter().notifyDataSetChanged();
suggestionsInProgress = false;
}
super.handleMessage(msg);
}
};
代码示例来源:origin: guanpj/JReadHub
private void initSuggestionData(Cursor cursor) {
mSearchView.setSuggestionsAdapter(new SimpleCursorAdapter(getContext(), R.layout.item_search_suggestion,
cursor, new String[] {"keyWord"}, new int[] {R.id.txt_sug}, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER));
mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionSelect(int position) {
return false;
}
@Override
public boolean onSuggestionClick(int position) {
cursor.moveToPosition(position);
mSearchView.setQuery(cursor.getString(cursor.getColumnIndex("keyWord")), true);
mSearchView.clearFocus();
if (!cursor.isClosed()) {
cursor.close();
}
return true;
}
});
}
代码示例来源:origin: tomahawk-player/tomahawk-android
@Override
public boolean onQueryTextChange(String newText) {
Cursor cursor = DatabaseHelper.get().getSearchHistoryCursor(newText);
if (cursor.getCount() != 0) {
String[] columns = new String[]{
TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY};
int[] columnTextId = new int[]{android.R.id.text1};
SuggestionSimpleCursorAdapter simple = new SuggestionSimpleCursorAdapter(
getBaseContext(), R.layout.searchview_dropdown_item,
cursor, columns, columnTextId, 0);
if (searchView.getSuggestionsAdapter() != null
&& searchView.getSuggestionsAdapter().getCursor() != null) {
searchView.getSuggestionsAdapter().getCursor().close();
}
searchView.setSuggestionsAdapter(simple);
return true;
} else {
cursor.close();
return false;
}
}
});
代码示例来源:origin: Phantast/smartnavi
@Override
public boolean onQueryTextChange(String query) {
// min 3 chars before autocomplete
if (query.length() >= Config.PLACES_SEARCH_QUERY_CHARACTER_LIMIT) {
// prevent hammering
if (!suggestionsInProgress) {
// get suggestions
new PlacesAutoComplete().execute(query);
suggestionsInProgress = true;
}
} else {
// clear suggestion list
mSuggestionsAdapter = new SuggestionsAdapter(sbContext, new MatrixCursor(Config.COLUMNS));
searchView.setSuggestionsAdapter(mSuggestionsAdapter);
searchView.getSuggestionsAdapter().notifyDataSetChanged();
}
return true;
}
});
代码示例来源:origin: Phantast/smartnavi
@SuppressLint("HandlerLeak")
private void prepareSearchView() {
searchView.setSuggestionsAdapter(mSuggestionsAdapter);
内容来源于网络,如有侵权,请联系作者删除!