use of com.actionbarsherlock.widget.SearchView in project little-bear-dictionary by daimajia.
the class QueryWordFragment method onCreateOptionsMenu.
@SuppressLint("NewApi")
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
mSearchView = new SearchView(mActionBar.getThemedContext());
mSearchView.setQueryHint(getActivity().getString(R.string.query_hint));
Theme theme = getActivity().getTheme();
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) mSearchView.findViewById(R.id.abs__search_src_text);
TypedValue typedValue = new TypedValue();
if (theme.resolveAttribute(R.attr.search_view_text_color, typedValue, true)) {
autoCompleteTextView.setTextColor(typedValue.data);
} else {
autoCompleteTextView.setTextColor(Color.BLACK);
}
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
layoutParams.setMargins(0, 0, 15, 0);
mActionBar.setCustomView(mSearchView, layoutParams);
inflater.inflate(R.menu.search_split_menu, menu);
mSearchView.setOnQueryTextListener(this);
mSearchView.setId(android.R.id.inputArea);
mSearchView.setIconifiedByDefault(true);
}
Aggregations