本文整理汇总了Java中android.support.v7.widget.SearchView.OnQueryTextListener方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.OnQueryTextListener方法的具体用法?Java SearchView.OnQueryTextListener怎么用?Java SearchView.OnQueryTextListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.OnQueryTextListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_navigation, menu);
MenuItem searchViewItem = menu.findItem(R.id.action_search);
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) searchViewItem.getActionView();
searchView.setQueryHint("Search");
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);// Do not iconify the widget; expand it by defaul
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
public boolean onQueryTextChange(String newText) {
// Adapter that will be filtered
classAdapter.getFilter().filter(newText);
return true;
}
public boolean onQueryTextSubmit(String query) {
return true;
}
};
searchView.setOnQueryTextListener(queryTextListener);
return true;
}
示例3: MuteableSearchViewOnQueryTextListener
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
public MuteableSearchViewOnQueryTextListener(final SearchView.OnQueryTextListener onQueryTextListener) {
this.onQueryTextListener = onQueryTextListener;
}