本文整理汇总了Java中android.widget.SearchView.setQueryRefinementEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setQueryRefinementEnabled方法的具体用法?Java SearchView.setQueryRefinementEnabled怎么用?Java SearchView.setQueryRefinementEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setQueryRefinementEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureSearchWidget
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void configureSearchWidget(
Activity activity, MenuItem menuItem, final TrackController trackController) {
SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menuItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
searchView.setQueryRefinementEnabled(true);
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
// Hide and show trackController when search widget has focus/no focus
if (trackController != null) {
if (hasFocus) {
trackController.hide();
} else {
trackController.show();
}
}
}
});
}
示例2: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItem importItem = menu.findItem(R.id.action_import);
importItem.setVisible(true);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getString(R.string.search));
searchView.onActionViewExpanded();
searchView.clearFocus();
searchView.setSubmitButtonEnabled(false);
searchView.setQueryRefinementEnabled(false);
searchView.setOnQueryTextListener(this);
}