Search in sources :

Example 6 with SearchView

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);
}
Also used : SearchView(com.actionbarsherlock.widget.SearchView) Theme(android.content.res.Resources.Theme) ActionBar(com.actionbarsherlock.app.ActionBar) AutoCompleteTextView(android.widget.AutoCompleteTextView) TypedValue(android.util.TypedValue) SuppressLint(android.annotation.SuppressLint)

Aggregations

SearchView (com.actionbarsherlock.widget.SearchView)6 SuppressLint (android.annotation.SuppressLint)2 MenuInflater (com.actionbarsherlock.view.MenuInflater)2 SearchManager (android.app.SearchManager)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Theme (android.content.res.Resources.Theme)1 MatrixCursor (android.database.MatrixCursor)1 Bundle (android.os.Bundle)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ActionBar (com.actionbarsherlock.app.ActionBar)1 QueryWordFragment (com.zhan_dui.dictionary.fragments.QueryWordFragment)1 SearchedTrackListActivity (io.recom.howabout.category.music.activity.SearchedTrackListActivity)1 AlertDialog (org.holoeverywhere.app.AlertDialog)1