本文整理了Java中android.support.v7.widget.SearchView.setOnCloseListener()
方法的一些代码示例,展示了SearchView.setOnCloseListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setOnCloseListener()
方法的具体详情如下:
包路径:android.support.v7.widget.SearchView
类名称:SearchView
方法名:setOnCloseListener
暂无
代码示例来源:origin: smuyyh/BookReader
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: hidroh/materialistic
@Test
public void testSearchView() {
SearchView searchView = (SearchView) actionViewResolver.getActionView(mock(MenuItem.class));
verify(searchView, atLeastOnce()).setOnSearchClickListener(searchViewClickListener.capture());
verify(searchView, atLeastOnce()).setOnCloseListener(searchViewCloseListener.capture());
searchViewClickListener.getAllValues()
.get(searchViewClickListener.getAllValues().size() - 1)
.onClick(searchView);
assertFalse(((FavoriteFragment) fragment).startActionMode(null));
SearchView.OnCloseListener closeListener = searchViewCloseListener.getAllValues()
.get(searchViewCloseListener.getAllValues().size() - 1);
closeListener.onClose();
assertEquals(2, adapter.getItemCount());
((FavoriteFragment) fragment).filter("ask");
verify(favoriteManager, times(2)).attach(observerCaptor.capture(), any());
when(favoriteManager.getSize()).thenReturn(1);
when(favoriteManager.getItem(eq(0))).thenReturn(new TestFavorite(
"2", "http://example.com", "ask HN", System.currentTimeMillis()));
observerCaptor.getValue().onChanged();
assertEquals(1, adapter.getItemCount());
reset(searchView);
closeListener.onClose();
verify(searchView).setQuery(eq(FavoriteActivity.EMPTY_QUERY), eq(true));
}
代码示例来源:origin: hidroh/materialistic
private void createSearchView(MenuItem menuSearch) {
final SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
searchView.setQueryHint(getString(R.string.hint_search_saved_stories));
searchView.setSearchableInfo(((SearchManager) getActivity()
.getSystemService(Context.SEARCH_SERVICE))
.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconified(!mSearchViewExpanded);
searchView.setQuery(mFilter, false);
searchView.setOnSearchClickListener(v -> {
mSearchViewExpanded = true;
v.requestFocus();
});
searchView.setOnCloseListener(() -> {
// trigger a dummy empty search intent, as empty query does not get submitted
searchView.setQuery(FavoriteActivity.EMPTY_QUERY, true);
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: 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: Odoo-mobile/framework
public void setHasSearchView(IOnSearchViewChangeListener listener,
Menu menu, int menu_id) {
mOnSearchViewChangeListener = listener;
mSearchView = (SearchView) MenuItemCompat.getActionView(menu
.findItem(menu_id));
if (mSearchView != null) {
mSearchView.setOnCloseListener(closeListener);
mSearchView.setOnQueryTextListener(searchViewQueryListener);
mSearchView.setIconifiedByDefault(true);
}
}
代码示例来源:origin: fennifith/Status
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
resetItem = menu.findItem(R.id.action_reset);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
adapter.filter(viewPager.getCurrentItem(), query.toLowerCase());
appbar.setExpanded(true);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.filter(viewPager.getCurrentItem(), newText.toLowerCase());
appbar.setExpanded(true);
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
adapter.filter(viewPager.getCurrentItem(), null);
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: calvinaquino/LNReader-Android
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: Swati4star/Images-to-PDF
mSearchView.setOnCloseListener(() -> {
populatePdfList();
return false;
代码示例来源:origin: brarcher/budget-watch
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnCloseListener(new SearchView.OnCloseListener()
代码示例来源:origin: GitLqr/MaterialDesignDemo
mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: gigabytedevelopers/FireFiles
mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: materialos/android-icon-pack
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.icons, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_icons));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final BaseThemedActivity act = (BaseThemedActivity) getActivity();
TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
代码示例来源:origin: materialos/android-icon-pack
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.wallpapers, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_wallpapers));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
代码示例来源:origin: materialos/android-icon-pack
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.zooper, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_widgets));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
代码示例来源:origin: materialos/android-icon-pack
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.kustom, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(getSearchHintRes()));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
代码示例来源:origin: bigsinger/fakegps
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
代码示例来源:origin: Leaking/WeGit
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
内容来源于网络,如有侵权,请联系作者删除!