本文整理汇总了Java中android.support.v7.widget.SearchView.setImeOptions方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setImeOptions方法的具体用法?Java SearchView.setImeOptions怎么用?Java SearchView.setImeOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setImeOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_category, menu);
MenuItem item = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) item.getActionView();
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mBookCategoryRecyclerViewAdapter.getFilter().filter(newText);
return true;
}
});
}
示例2: setupSearchView
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void setupSearchView(MenuItem searchItem) {
if (searchItem != null) {
MenuItemCompat.setOnActionExpandListener(searchItem, this);
SearchManager searchManager = (SearchManager) (getActivity()
.getSystemService(Context.SEARCH_SERVICE));
searchView = (SearchView) searchItem.getActionView();
if (searchView != null) {
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getActivity().getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.clearFocus();
searchView.setOnQueryTextListener(this);
setupSearchOptions(searchView);
}
}
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.questions, menu);
// Setup search widget in action bar
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override public boolean onQueryTextSubmit(String query) {
return false;
}
@Override public boolean onQueryTextChange(String newText) {
presenter.search(newText);
return true;
}
});
return true;
}