本文整理了Java中android.support.v7.widget.SearchView.setOnQueryTextListener()
方法的一些代码示例,展示了SearchView.setOnQueryTextListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setOnQueryTextListener()
方法的具体详情如下:
包路径:android.support.v7.widget.SearchView
类名称:SearchView
方法名:setOnQueryTextListener
暂无
代码示例来源:origin: jgilfelt/chuck
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.chuck_main, menu);
MenuItem searchMenuItem = menu.findItem(R.id.search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(this);
searchView.setIconifiedByDefault(true);
super.onCreateOptionsMenu(menu, inflater);
}
代码示例来源:origin: smuyyh/BookReader
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
代码示例来源:origin: aa112901/remusic
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getResources().getString(R.string.search_net_music));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: aa112901/remusic
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getResources().getString(R.string.search_local_music));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: smuyyh/BookReader
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
代码示例来源:origin: naman14/Timber
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getString(R.string.search_library));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
代码示例来源:origin: YoKeyword/IndexableRecyclerView
private void initSearch() {
getSupportFragmentManager().beginTransaction().hide(mSearchFragment).commit();
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText.trim().length() > 0) {
if (mSearchFragment.isHidden()) {
getSupportFragmentManager().beginTransaction().show(mSearchFragment).commit();
}
} else {
if (!mSearchFragment.isHidden()) {
getSupportFragmentManager().beginTransaction().hide(mSearchFragment).commit();
}
}
mSearchFragment.bindQueryText(newText);
return false;
}
});
}
代码示例来源:origin: ImangazalievM/Bubbble
public void initOptionsMenu(Menu menu) {
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) myActionMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchQueryListener() {
@Override
public boolean onQueryTextSubmit(String query) {
shotsSearchPresenter.onNewSearchQuery(query);
return true;
}
});
}
代码示例来源:origin: tupunco/tup.dota2recipe
/**
* setup Items Searchable SearchView
*
* @param searchItem
*/
private void setupItemsSearchView(MenuItem searchItem) {
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
// TODO SearchableInfo
if (mSearchView != null)
mSearchView.setOnQueryTextListener(this);
}
代码示例来源:origin: SecUSo/privacy-friendly-todo-list
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu,inflater);
inflater.inflate(R.menu.main, menu);
inflater.inflate(R.menu.search, menu);
inflater.inflate(R.menu.add_list, menu);
MenuItem searchItem = menu.findItem(R.id.ac_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
}
代码示例来源:origin: sorz/TinyKeePass
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_search, menu);
MenuItem searchMenu = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchMenu.getActionView();
searchView.setOnQueryTextListener(this);
super.onCreateOptionsMenu(menu, inflater);
}
代码示例来源:origin: CodemateLtd/Android-Cucumber-BDD-Sample
private void initializeViews() {
bookAdapter = new BookAdapter();
RecyclerView bookRecycler = (RecyclerView) findViewById(R.id.bookRecycler);
bookRecycler.setLayoutManager(new LinearLayoutManager(this));
bookRecycler.setAdapter(bookAdapter);
SearchView searchView = (SearchView) findViewById(R.id.searchView);
searchView.setOnQueryTextListener(this);
}
代码示例来源:origin: Cleveroad/MusicBobber
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.clear();
getMenuInflater().inflate(R.menu.main, menu);
MenuItem searchItem = menu.findItem(R.id.item_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
return true;
}
代码示例来源:origin: Cleveroad/PlayWidget
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.clear();
getMenuInflater().inflate(R.menu.main, menu);
MenuItem searchItem = menu.findItem(R.id.item_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
return true;
}
代码示例来源:origin: DF1E/SimpleExplorer
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_menu, menu);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
代码示例来源: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: nglauber/dominando_android2
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_hotel, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView)
MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getString(R.string.hint_busca));
MenuItemCompat.setOnActionExpandListener(searchItem, this);
return true;
}
代码示例来源:origin: nglauber/dominando_android2
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_hotel, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView)
MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getString(R.string.hint_busca));
MenuItemCompat.setOnActionExpandListener(searchItem, this);
return true;
}
代码示例来源:origin: erikcaffrey/Android-Spotify-MVP
private void setupSearchView(Menu menu) {
SearchManager searchManager =
(SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setMaxWidth(toolbar.getWidth());
searchView.setOnQueryTextListener(this);
}
内容来源于网络,如有侵权,请联系作者删除!