本文整理匯總了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;
}