本文整理了Java中android.widget.SearchView.setQuery()
方法的一些代码示例,展示了SearchView.setQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setQuery()
方法的具体详情如下:
包路径:android.widget.SearchView
类名称:SearchView
方法名:setQuery
暂无
代码示例来源:origin: bumptech/glide
@Override
public boolean onQueryTextSubmit(String query) {
executeSearch(query);
searchView.setQuery("", false /*submit*/);
return true;
}
代码示例来源:origin: stackoverflow.com
final MenuItem searchMenuItem = optionsMenu.findItem(R.id.search);
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean queryTextFocused) {
if(!queryTextFocused) {
searchMenuItem.collapseActionView();
searchView.setQuery("", false);
}
}
});
代码示例来源:origin: stackoverflow.com
private SearchView searchView;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_menu, menu);
searchView = (SearchView) menu.findItem(R.id.menu_search)
.getActionView(); // set the reference to the searchView
searchView.setOnQueryTextListener(this);
searchMenuItem = (MenuItem) menu.findItem(R.id.menu_search);
searchMenuItem.expandActionView(); // expand the search action item automatically
searchView.setQuery("<put your search term here>", false); // fill in the search term by default
searchView.clearFocus(); // close the keyboard on load
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
performNewSearch(query);
searchView.clearFocus();
return true;
}
代码示例来源:origin: commonsguy/cw-omnibus
private void configureSearchView(Menu menu) {
MenuItem search=menu.findItem(R.id.search);
search.setOnActionExpandListener(this);
sv=(SearchView)search.getActionView();
sv.setOnQueryTextListener(this);
sv.setSubmitButtonEnabled(true);
sv.setIconifiedByDefault(true);
if (initialQuery != null) {
sv.setIconified(false);
search.expandActionView();
sv.setQuery(initialQuery, true);
}
}
代码示例来源:origin: commonsguy/cw-omnibus
private void configureSearchView(Menu menu) {
MenuItem search=menu.findItem(R.id.search);
sv=(SearchView)search.getActionView();
sv.setOnQueryTextListener(this);
sv.setOnCloseListener(this);
sv.setSubmitButtonEnabled(false);
sv.setIconifiedByDefault(true);
if (initialQuery != null) {
sv.setIconified(false);
search.expandActionView();
sv.setQuery(initialQuery, true);
}
}
代码示例来源:origin: stackoverflow.com
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
SearchView searchView = new SearchView(this);
actionBar.setCustomView(searchView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
searchView.setQuery("test",true);
searchView.setFocusable(true);
searchView.setIconified(false);
searchView.requestFocusFromTouch();
}
代码示例来源:origin: stackoverflow.com
int indexColumnSuggestion = cursor.getColumnIndex( SuggestionsDatabase.FIELD_SUGGESTION);
searchView.setQuery(cursor.getString(indexColumnSuggestion), false);
代码示例来源:origin: stackoverflow.com
@Override
public boolean onPrepareOptionsMenu (Menu menu) {
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQuery("", false);
// rest of code...
}
代码示例来源:origin: stackoverflow.com
View root;
SearchView searchView;
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
root = findViewById(R.id.rootLayout);
searchView = (SearchView) findViewById(R.id.searchView);
}
@Override
protected void onResume() {
super.onResume();
searchView.setQuery("", false);
root.requestFocus();
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: jahirfiquitiva/IconShowcase
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus && item != null) {
item.collapseActionView();
if (v instanceof SearchView) {
((SearchView) v).setQuery("", false);
}
}
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: clemensbartz/essential-launcher
@Override
public boolean onMenuItemActionCollapse(final MenuItem item) {
final View view = item.getActionView();
if (view instanceof SearchView) {
final SearchView searchView = (SearchView) view;
searchView.setQuery("", true);
}
return true;
}
});
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean onClose() {
if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery(null, true);
}
return true;
}
代码示例来源:origin: stackoverflow.com
@Override
public void onPrepareOptionsMenu(Menu menu) {
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
if(!TextUtils.isEmpty(mSearch)){
searchView.setQuery(mSearch, false);
searchView.setIconified(false);
searchView.clearFocus();
}
}
代码示例来源:origin: stackoverflow.com
final MenuItem searchMenuItem = optionsMenu.findItem(R.id.search);
final SearchView searchView =
(SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean queryTextFocused) {
if(!queryTextFocused) {
searchMenuItem.collapseActionView();
searchView.setQuery("", false);
}
}
});
代码示例来源:origin: WeAreFairphone/FP2-Launcher
public void smartHide() {
if (mActive && !mAnimating) {
if (mIsKeyboardShowing) {
hideKeyboard();
} else if (!TextUtils.isEmpty(mSearchView.getQuery())) {
mSearchView.setQuery("", false);
} else {
hideSearchView();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!