List of usage examples for android.app SearchManager SUGGEST_COLUMN_TEXT_2
String SUGGEST_COLUMN_TEXT_2
To view the source code for android.app SearchManager SUGGEST_COLUMN_TEXT_2.
Click Source Link
From source file:com.svpino.longhorn.activities.DashboardActivity.java
private void performSearch(String query) { this.stockListFragment.hideContextualActionBar(); Cursor cursor = DataProvider.search(getApplicationContext(), query); if (this.searchDialog == null || !this.searchDialog.isShowing()) { this.searchDialog = new Dialog(this); this.searchDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); this.searchDialog.setContentView(R.layout.dialog); TextView messageTextView = (TextView) this.searchDialog.findViewById(R.id.messageTextView); TextView titleTextView = (TextView) this.searchDialog.findViewById(R.id.titleTextView); ListView listView = (ListView) this.searchDialog.findViewById(R.id.listView); if (cursor != null && cursor.getCount() > 0) { titleTextView.setText(String.format(getString(R.string.dialog_search_title), query)); messageTextView.setVisibility(View.GONE); String[] from = new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2, LonghornDatabase.KEY_EXCHANGE_SYMBOL }; int[] to = new int[] { R.id.nameTextView, R.id.descriptionTextView, R.id.additionalTextView }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.dialog_item, cursor, from, to, 0); adapter.setViewBinder(new ViewBinder() { @Override//from w w w. j ava2 s . co m public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (columnIndex == 0) { ((View) view.getParent()).setTag(cursor.getString(columnIndex)); } return false; } }); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Cursor cursor = (Cursor) adapterView.getItemAtPosition(position); addStockToWatchList(cursor.getString(0)); DashboardActivity.this.searchDialog.dismiss(); } }); } else { titleTextView.setText(getString(R.string.dialog_search_empty_title)); messageTextView.setText(String.format(getString(R.string.dialog_search_empty_message), query)); messageTextView.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); } this.searchDialog.show(); } }
From source file:fr.openbike.android.database.OpenBikeDBAdapter.java
public Cursor getStationsMatches(String query, String[] columns) { String table = STATIONS_VIRTUAL_TABLE; try {/* w ww . j a v a2 s. c o m*/ Integer.parseInt(query); table = BaseColumns._ID; } catch (NumberFormatException ex) { } query += "*"; // Network is not in argument list because when I do so, it doesn't work // ! String s = "SELECT vs._id, vs._id as " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID + ", 'n ' || vs._id as " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ", vs.name as " + SearchManager.SUGGEST_COLUMN_TEXT_1 + " FROM" + " virtual_stations vs WHERE " + table + " MATCH ? AND vs.network = " + mPreferences.getInt(AbstractPreferencesActivity.NETWORK_PREFERENCE, AbstractPreferencesActivity.NO_NETWORK) + ";"; Cursor cursor = mDb.rawQuery(s, new String[] { query }); /* * Cursor cursor = mDb.query(STATIONS_VIRTUAL_TABLE, new String[] { * BaseColumns._ID, "'n ' || " + BaseColumns._ID + " as " + * SearchManager.SUGGEST_COLUMN_TEXT_2, BaseColumns._ID + " as " + * SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, KEY_NAME + " as " + * SearchManager.SUGGEST_COLUMN_TEXT_1 }, table + " MATCH ? AND " + * KEY_NETWORK + " = ?", new String[] { query, * String.valueOf(mCurrentNetwork) }, null, null, null); */ /* * Cursor cursor = mDb.rawQuery( "SELECT _id " + * SearchManager.SUGGEST_COLUMN_TEXT_2 + ", _id " + * SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID + ", name " + * SearchManager.SUGGEST_COLUMN_TEXT_1 + " FROMvirtual_stations;" * "WHERE " + table + " MATCH ?;", null new String[] { query, * String.valueOf(mCurrentNetwork) }); */ if (cursor == null) { return null; } /* * else if (!cursor.moveToFirst()) { cursor.close(); return null; * * } */ return cursor; }
From source file:de.sourcestream.movieDB.MainActivity.java
/** * Initialize the contents of the Activity's standard options menu. * This is only called once, the first time the options menu is displayed. * * @param menu the options menu in which we place our items. * @return You must return true for the menu to be displayed; if you return false it will not be shown. *//* w w w .j a v a2 s. co m*/ @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); searchViewItem = menu.findItem(R.id.search); searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem); searchView.setQueryHint(getResources().getString(R.string.search_hint)); searchView.setOnQueryTextListener(searchViewOnQueryTextListener); searchView.setOnSuggestionListener(searchSuggestionListener); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchViewItemC = (SearchView) menu.findItem(R.id.search).getActionView(); searchViewItemC.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); String[] from = { SearchManager.SUGGEST_COLUMN_ICON_1, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2 }; int[] to = { R.id.posterPath, R.id.title, R.id.info }; searchAdapter = new SimpleCursorAdapter(getApplicationContext(), R.layout.suggestionrow, null, from, to, 0) { @Override public void changeCursor(Cursor cursor) { super.swapCursor(cursor); } }; searchViewItemC.setSuggestionsAdapter(searchAdapter); MenuItemCompat.setOnActionExpandListener(searchViewItem, onSearchViewItemExpand); return true; }