本文整理汇总了Java中android.support.v7.widget.SearchView.setOnCloseListener方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setOnCloseListener方法的具体用法?Java SearchView.setOnCloseListener怎么用?Java SearchView.setOnCloseListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setOnCloseListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnCloseListener(this);
searchView.setOnQueryTextListener(this);
// setOnSuggestionListener -> for selection of a suggestion
// setSuggestionsAdapter
return true;
}
示例2: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.list_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnCloseListener(() -> {
postOnResumeEvents.onNext(new GetPaginatedUsersEvent(viewState == null ? -1 : viewState.getLastId()));
return false;
});
eventObservable = eventObservable.mergeWith(RxSearchView.queryTextChanges(searchView)
.filter(charSequence -> !charSequence.toString().isEmpty())
.map(query -> new SearchUsersEvent(query.toString()))
.throttleLast(100, TimeUnit.MILLISECONDS)
.debounce(200, TimeUnit.MILLISECONDS)
.doOnEach(searchUsersEvent -> Log.d("SearchEvent", FIRED)));
return super.onCreateOptionsMenu(menu);
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_chm_reader, menu);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);//在菜单中找到对应控件的item
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
mWebView.clearMatches();
return false;
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mWebView.findAllAsync(newText);
try {
for (Method m : WebView.class.getDeclaredMethods()) {
if (m.getName().equals("setFindIsUp")) {
m.setAccessible(true);
m.invoke(mWebView, true);
break;
}
}
} catch (Exception ignored) {
}
return false;
}
});
return true;
}
示例4: onPrepareOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
searchItem = menu.findItem(R.id.search);
searchItem.setOnActionExpandListener(new SearchViewExpandListener(menu));
searchView = (SearchView) searchItem.getActionView();
searchView.setIconified(false);
onQueryTextListener = new MuteableSearchViewOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
getFragment().onSearchQuerySubmitted(query);
return false;
}
@Override
public boolean onQueryTextChange(final String query) {
getFragment().onSearchQueryChanged(query);
return false;
}
});
searchView.setOnQueryTextListener(onQueryTextListener);
searchView.setOnCloseListener(() -> {
getFragment().onSearchClosed();
return false;
});
getFragment().onOptionsMenuPrepared();
return super.onPrepareOptionsMenu(menu);
}
示例5: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.toolbar_menu, menu);
MenuItem searchItem = menu.findItem(R.id.search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchAutoComplete = searchView.findViewById(R.id.search_src_text);
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switchLayout();
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
switchLayout();
return false;
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
final List<General> filteredList = filter(DataSupport.findAll(General.class), newText);
adapter.setNewData(filteredList);
adapter.notifyDataSetChanged();
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
示例6: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override+
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
// Search
searchItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (adapter != null)
adapter.getFilter().filter(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if (adapter != null)
adapter.getFilter().filter(newText);
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
if (adapter != null)
adapter.getFilter().filter(null);
return true;
}
});
return true;
}
示例7: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
getMenuInflater().inflate(R.menu.white_list_activity_menu, menu);
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.ab_search).getActionView();
selectAll=menu.findItem(R.id.select_all);
setSelection=menu.findItem(R.id.setSelection);
final SearchView.SearchAutoComplete searchEditText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.white));
searchView.setQueryHint("Search");
// 将搜索按钮放到搜索输入框的外边
searchView.setIconifiedByDefault(false);
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
refreshListByQuery(searchView.getQuery().toString());
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
refreshListByQuery("");
return false;
}
});
// MenuItem menuItem=menu.add("恢复默认");
// menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
// menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// if(mSelectedApplicationInfos==null){
// SnackBarUtil.show(toolbar,R.string.wait_until_loaded);
// return true;
// }
// for (AppListAdapter.ApplicationInfoWrap app:mSelectedApplicationInfos){
// app.isSelected=false;
// }
// mSelectedApplicationInfos.clear();
// mAppAdapter.notifyDataSetChanged();
// refreshTV();
// return true;
// }
// });
}
refreshMenu(false);
return true;
}
示例8: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
getMenuInflater().inflate(R.menu.white_list_activity_menu, menu);
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.ab_search).getActionView();
selectAll=menu.findItem(R.id.select_all);
setSelection=menu.findItem(R.id.setSelection);
final SearchView.SearchAutoComplete searchEditText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.white));
searchView.setQueryHint("Search");
// 将搜索按钮放到搜索输入框的外边
searchView.setIconifiedByDefault(false);
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
refreshListByQuery(searchView.getQuery().toString());
return true;
}
});
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
refreshListByQuery("");
return false;
}
});
// MenuItem menuItem=menu.add("恢复默认");
// menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
// menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
// @Override
// public boolean onMenuItemClick(MenuItem item) {
// if(mSelectedApplicationInfos==null){
// SnackBarUtil.show(toolbar,R.string.wait_until_loaded);
// return true;
// }
// for (AppListAdapter.ApplicationInfoWrap app:mSelectedApplicationInfos){
// app.isSelected=false;
// }
// mSelectedApplicationInfos.clear();
// mAppAdapter.notifyDataSetChanged();
// refreshTV();
// return true;
// }
// });
}
setSelection.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
showPopupMenu(toolbar);
return true;
}
});
refreshMenu(false);
return true;
}
示例9: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) item.getActionView();
if (searchView != null) {
searchView.setQueryHint(getResources().getString(R.string.query_hint));
searchView.setIconified(true);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
System.out.println("on search submit: " + query);
Thread searchThread = new Thread() {
public void run() {
result.needsClear();
result.downloading();
List<Crate> crates = Networking.searchCrate(query, 1);
for (Crate crate : crates) {
result.onResult(crate);
}
searchView.post(() -> searchView.clearFocus());
}
};
searchThread.start();
MainActivity.result.onResult(new Crate());
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.length() > 0) {
if (summarySearchPager.getCurrentItem() != 1) {
summarySearchPager.setCurrentItem(1, true);
}
}
return false;
}
});
searchView.setOnCloseListener(() -> {
System.out.println("on search close");
summarySearchPager.setCurrentItem(0, true);
return false;
});
}
return true;
}