本文整理了Java中android.widget.SearchView.setOnCloseListener()
方法的一些代码示例,展示了SearchView.setOnCloseListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setOnCloseListener()
方法的具体详情如下:
包路径:android.widget.SearchView
类名称:SearchView
方法名:setOnCloseListener
暂无
代码示例来源:origin: stackoverflow.com
mSearchView.setOnCloseListener(new OnCloseListener()
代码示例来源:origin: k9mail/k-9
private void configureFolderSearchView(Menu menu) {
final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
actionBar.setTitle(R.string.filter_folders_action);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
return true;
}
});
folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
actionBar.setTitle(R.string.folders_title);
return false;
}
});
}
代码示例来源: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
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: kingargyle/adt-leanback-support
public static void setOnCloseListener(Object searchView, Object listener) {
((SearchView) searchView).setOnCloseListener((OnCloseListener) listener);
}
代码示例来源:origin: stackoverflow.com
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setMaxWidth(5000);
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ActionBar actionBar = getActionBar();
if (actionBar != null)
actionBar.setDisplayShowHomeEnabled(false);
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
ActionBar actionBar = getActionBar();
if (actionBar != null)
actionBar.setDisplayShowHomeEnabled(true);
return false;
}
});
代码示例来源:origin: stackoverflow.com
SearchView sv=(SearchView)findViewById(R.id.searchView);
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
//when the text change
search(s);
return false;
}
});
sv.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
//when canceling the search
return false;
}
});
代码示例来源:origin: algolia/instantsearch-android
/**
* Sets a listener to inform when the user closes the SearchView.
*
* @param listener the listener to call when the user closes the SearchView.
*/
public void setOnCloseListener(@NonNull final SearchView.OnCloseListener listener) {
if (searchView != null) {
searchView.setOnCloseListener(listener);
} else if (supportView != null) {
supportView.setOnCloseListener(new android.support.v7.widget.SearchView.OnCloseListener() {
@Override public boolean onClose() {
return listener.onClose();
}
});
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
代码示例来源:origin: stackoverflow.com
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.bookings_list_menu, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnSearchClickListener(...);
searchView.setOnCloseListener(...);
searchView.setOnQueryTextListener(...);
super.onCreateOptionsMenu(menu, inflater);
}
代码示例来源:origin: algolia/instantsearch-android
/**
* Sets a listener to inform when the user closes the SearchView.
*
* @param listener the listener to call when the user closes the SearchView.
*/
public void setOnCloseListener(@NonNull final android.support.v7.widget.SearchView.OnCloseListener listener) {
if (searchView != null) {
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override public boolean onClose() {
return listener.onClose();
}
});
} else if (supportView != null) {
supportView.setOnCloseListener(listener);
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
}
代码示例来源:origin: commonsguy/cw-androidarch
private void configureSearchView(Menu menu) {
MenuItem search=menu.findItem(R.id.search);
sv=(SearchView)search.getActionView();
sv.setOnQueryTextListener(this);
sv.setOnCloseListener(this);
sv.setSubmitButtonEnabled(true);
sv.setIconifiedByDefault(true);
}
代码示例来源:origin: stackoverflow.com
if (searchView != null) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: stackoverflow.com
// e.g in onCreateView in my Fragment, wire up the SearchView:
MenuItem searchMenuItem = toolbar.getMenu().findItem(R.id.search_menu_item);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
// and setup listeners (implementation is shown later)
searchView.setOnSuggestionListener(this);
searchView.setOnQueryTextListener(this);
searchView.setOnCloseListener(this);
// then raid the SearchView so search begins on 0 chars!
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
autoCompleteTextView.setThreshold(0);
// and set the suggestions adapter so we can use a Loader to do the queries
SuggestionCursorAdapter suggestionCursorAdapter = new SuggestionCursorAdapter(getContext(), null, 0);
searchView.setSuggestionsAdapter(suggestionAdapter);
代码示例来源:origin: li2/learning-android-open-source
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: li2/learning-android-open-source
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: li2/learning-android-open-source
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
mSearchView = new MySearchView(getActivity());
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setIconifiedByDefault(true);
item.setActionView(mSearchView);
}
代码示例来源:origin: Yaerin/XposedHider
sv.setOnCloseListener(() -> {
mAdapter.setAppList(mApps);
mAdapter.notifyDataSetChanged();
内容来源于网络,如有侵权,请联系作者删除!