本文整理汇总了Java中android.support.v7.widget.SearchView.setInputType方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setInputType方法的具体用法?Java SearchView.setInputType怎么用?Java SearchView.setInputType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setInputType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_courses, menu);
MenuItem item = menu.findItem(R.id.action_courses_search);
SearchView searchView = (SearchView) item.getActionView();
searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
searchView.setOnQueryTextListener(this);
if (!"".equals(lastQuery)) {
searchView.setQuery(lastQuery, false);
item.expandActionView();
}
}
示例2: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_search_view, menu);
MenuItem menuItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) menuItem.getActionView();
mSearchView.setInputType(InputType.TYPE_CLASS_NUMBER);
mSearchView.setQueryHint(getString(R.string.fragment_search_search_view_hint));
mSearchView.setOnQueryTextListener(this);
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.action_search);
try {
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setQueryHint(getString(R.string.search_by_title));
mSearchView.setInputType(InputType.TYPE_CLASS_TEXT);
mSearchView.setOnQueryTextListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView =
(SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
if (isInputMode) {
MenuItemCompat.expandActionView(searchItem);
} else {
MenuItemCompat.collapseActionView(searchItem);
}
MenuItemCompat.setOnActionExpandListener(searchItem, this);
AutoCompleteTextView autoCompleteTextView = searchView
.findViewById(android.support.v7.appcompat.R.id.search_src_text);
autoCompleteTextView.setThreshold(0);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,
R.layout.layout_item_simple_list, mPresenter.getSearchRecordList()));
autoCompleteTextView.setDropDownBackgroundDrawable(new ColorDrawable(ViewUtils.getWindowBackground(getActivity())));
autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
onQueryTextSubmit(parent.getAdapter().getItem(position).toString());
});
return super.onCreateOptionsMenu(menu);
}