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