Search in sources :

Example 71 with SearchView

use of android.support.v7.widget.SearchView in project MusicLake by caiyonglong.

the class SearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.onActionViewExpanded();
    searchView.setQueryHint(getString(R.string.search_tips));
    searchView.setOnQueryTextListener(this);
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView)

Example 72 with SearchView

use of android.support.v7.widget.SearchView in project kiwix-android by kiwix.

the class SearchActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    searchMenuItem.expandActionView();
    searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    if (searchText != null) {
        searchView.setQuery(searchText, false);
        mListView.setAdapter(mAutoAdapter);
        mAutoAdapter.getFilter().filter(searchText.toLowerCase());
    }
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            if (s.equals("")) {
                mListView.setAdapter(mDefaultAdapter);
            } else {
                mListView.setAdapter(mAutoAdapter);
                mAutoAdapter.getFilter().filter(s.toLowerCase());
            }
            return true;
        }
    });
    searchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return false;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            finish();
            return false;
        }
    });
    if (getIntent().hasExtra(Intent.EXTRA_PROCESS_TEXT)) {
        searchView.setQuery(getIntent().getStringExtra(Intent.EXTRA_PROCESS_TEXT), true);
    }
    if (getIntent().hasExtra(EXTRA_SEARCH)) {
        searchView.setQuery(getIntent().getStringExtra(EXTRA_SEARCH), true);
    }
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 73 with SearchView

use of android.support.v7.widget.SearchView in project YalpStore by yeriomin.

the class BaseActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSubmitButtonEnabled(true);
    suggestionsAdapter = new SimpleCursorAdapter(this, R.layout.suggestion_list_item, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_ICON_1 }, new int[] { R.id.text, R.id.icon }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    searchView.setSuggestionsAdapter(suggestionsAdapter);
    searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {

        @Override
        public boolean onSuggestionClick(int position) {
            triggerSearch((Cursor) suggestionsAdapter.getItem(position));
            return true;
        }

        @Override
        public boolean onSuggestionSelect(int position) {
            triggerSearch((Cursor) suggestionsAdapter.getItem(position));
            return true;
        }

        private void triggerSearch(Cursor cursor) {
            String data = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_DATA));
            String label = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
            search(data, !data.equals(label));
        }
    });
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            search(s, false);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            new SearchSuggestionTask(BaseActivity.this).execute(s);
            return false;
        }
    });
    return result;
}
Also used : SearchView(android.support.v7.widget.SearchView) SimpleCursorAdapter(android.support.v4.widget.SimpleCursorAdapter) Cursor(android.database.Cursor)

Example 74 with SearchView

use of android.support.v7.widget.SearchView in project NightSkyGuide by MTBehnke.

the class DSObjectsFragment method onCreateOptionsMenu.

// display this fragment's menu items
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_dsobjects_menu, menu);
    final SearchView searchView = (SearchView) menu.findItem(R.id.dso_search).getActionView();
    searchView.setOnQueryTextListener(new OnSearchTextListener());
}
Also used : SearchView(android.support.v7.widget.SearchView)

Example 75 with SearchView

use of android.support.v7.widget.SearchView in project memetastic by gsantner.

the class MainActivity method onCreateOptionsMenu.

// ########################
// ## Single line overrides
// ########################
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main__menu, menu);
    _searchItem = menu.findItem(R.id.action_search_meme);
    _searchView = (SearchView) _searchItem.getActionView();
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    _searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    _searchView.setQueryHint(getString(R.string.main__search_meme));
    if (_searchView != null) {
        _searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String query) {
                if (query != null) {
                    updateSearchFilter(query);
                }
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                if (newText != null) {
                    updateSearchFilter(newText);
                }
                return false;
            }
        });
        _searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    _searchItem.collapseActionView();
                    updateSearchFilter("");
                }
            }
        });
    }
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

SearchView (android.support.v7.widget.SearchView)151 MenuItem (android.view.MenuItem)88 View (android.view.View)56 SearchManager (android.app.SearchManager)37 RecyclerView (android.support.v7.widget.RecyclerView)35 TextView (android.widget.TextView)26 MenuInflater (android.view.MenuInflater)24 ImageView (android.widget.ImageView)20 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)19 MenuItemCompat (android.support.v4.view.MenuItemCompat)18 Toolbar (android.support.v7.widget.Toolbar)16 SearchView (android.widget.SearchView)12 ArrayList (java.util.ArrayList)11 ViewGroup (android.view.ViewGroup)10 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)10 Intent (android.content.Intent)9 ListView (android.widget.ListView)9 BindView (butterknife.BindView)9 AdapterView (android.widget.AdapterView)8 EditText (android.widget.EditText)8