use of android.support.v7.widget.SearchView in project MusicLake by caiyonglong.
the class SearchActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.onActionViewExpanded();
searchView.setQueryHint(getString(R.string.search_tips));
searchView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
use of android.support.v7.widget.SearchView in project kiwix-android by kiwix.
the class SearchActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
searchMenuItem.expandActionView();
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
if (searchText != null) {
searchView.setQuery(searchText, false);
mListView.setAdapter(mAutoAdapter);
mAutoAdapter.getFilter().filter(searchText.toLowerCase());
}
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
if (s.equals("")) {
mListView.setAdapter(mDefaultAdapter);
} else {
mListView.setAdapter(mAutoAdapter);
mAutoAdapter.getFilter().filter(s.toLowerCase());
}
return true;
}
});
searchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return false;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
if (getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT)) {
searchView.setQuery(getIntent().getStringExtra(Intent.EXTRA_PROCESS_TEXT), true);
}
if (getIntent().hasExtra(EXTRA_SEARCH)) {
searchView.setQuery(getIntent().getStringExtra(EXTRA_SEARCH), true);
}
return true;
}
use of android.support.v7.widget.SearchView in project YalpStore by yeriomin.
the class BaseActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSubmitButtonEnabled(true);
suggestionsAdapter = new SimpleCursorAdapter(this, R.layout.suggestion_list_item, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_ICON_1 }, new int[] { R.id.text, R.id.icon }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
searchView.setSuggestionsAdapter(suggestionsAdapter);
searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
@Override
public boolean onSuggestionClick(int position) {
triggerSearch((Cursor) suggestionsAdapter.getItem(position));
return true;
}
@Override
public boolean onSuggestionSelect(int position) {
triggerSearch((Cursor) suggestionsAdapter.getItem(position));
return true;
}
private void triggerSearch(Cursor cursor) {
String data = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_DATA));
String label = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
search(data, !data.equals(label));
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
search(s, false);
return false;
}
@Override
public boolean onQueryTextChange(String s) {
new SearchSuggestionTask(BaseActivity.this).execute(s);
return false;
}
});
return result;
}
use of android.support.v7.widget.SearchView in project NightSkyGuide by MTBehnke.
the class DSObjectsFragment method onCreateOptionsMenu.
// display this fragment's menu items
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_dsobjects_menu, menu);
final SearchView searchView = (SearchView) menu.findItem(R.id.dso_search).getActionView();
searchView.setOnQueryTextListener(new OnSearchTextListener());
}
use of android.support.v7.widget.SearchView in project memetastic by gsantner.
the class MainActivity method onCreateOptionsMenu.
// ########################
// ## Single line overrides
// ########################
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main__menu, menu);
_searchItem = menu.findItem(R.id.action_search_meme);
_searchView = (SearchView) _searchItem.getActionView();
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
_searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
_searchView.setQueryHint(getString(R.string.main__search_meme));
if (_searchView != null) {
_searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (query != null) {
updateSearchFilter(query);
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText != null) {
updateSearchFilter(newText);
}
return false;
}
});
_searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
_searchItem.collapseActionView();
updateSearchFilter("");
}
}
});
}
return true;
}
Aggregations