Search in sources :

Example 1 with OnQueryTextListener

use of android.support.v7.widget.SearchView.OnQueryTextListener in project MiMangaNu by raulhaag.

the class ServerListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.manga_server, menu);
    MenuItem search;
    search = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String s) {
            if (adapter != null)
                adapter.getFilter().filter(s);
            return false;
        }
    });
}
Also used : OnQueryTextListener(android.support.v7.widget.SearchView.OnQueryTextListener) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 2 with OnQueryTextListener

use of android.support.v7.widget.SearchView.OnQueryTextListener in project SharedPreferenceInspector by PrashamTrivedi.

the class SharedPreferencesItem method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_testmode) {
        getActivity().supportInvalidateOptionsMenu();
        changeTestMode();
    }
    if (id == R.id.action_search) {
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
        if (searchView != null) {
            searchView.setQueryHint(getString(R.string.searchHint));
            searchView.setOnQueryTextListener(new OnQueryTextListener() {

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

                @Override
                public boolean onQueryTextChange(String s) {
                    search(s);
                    return true;
                }
            });
        }
    }
    return super.onOptionsItemSelected(item);
}
Also used : OnQueryTextListener(android.support.v7.widget.SearchView.OnQueryTextListener) SearchView(android.support.v7.widget.SearchView)

Example 3 with OnQueryTextListener

use of android.support.v7.widget.SearchView.OnQueryTextListener in project frostwire by frostwire.

the class AudioPlayerActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Search view
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.player_search, menu);
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_player_search).getActionView();
    // Add voice search
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (searchManager != null) {
        final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
        searchView.setSearchableInfo(searchableInfo);
        // Perform the search
        searchView.setOnQueryTextListener(new OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(final String query) {
                // Open the search activity
                NavUtils.openSearch(AudioPlayerActivity.this, query);
                return true;
            }

            @Override
            public boolean onQueryTextChange(final String newText) {
                // Nothing to do
                return false;
            }
        });
    }
    // Favorite action
    menuInflater.inflate(R.menu.player_favorite, menu);
    // Share, ringtone, and equalizer
    menuInflater.inflate(R.menu.player_audio_player, menu);
    // Shuffle all
    menuInflater.inflate(R.menu.player_shuffle, menu);
    return super.onCreateOptionsMenu(menu);
}
Also used : OnQueryTextListener(android.support.v7.widget.SearchView.OnQueryTextListener) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager) SearchableInfo(android.app.SearchableInfo)

Example 4 with OnQueryTextListener

use of android.support.v7.widget.SearchView.OnQueryTextListener in project frostwire by frostwire.

the class BaseActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Search view
    getMenuInflater().inflate(R.menu.player_search, menu);
    final SearchView searchView = (SearchView) menu.findItem(R.id.menu_player_search).getActionView();
    // Add voice search
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
    if (searchView != null) {
        // rare NPE can occur
        searchView.setSearchableInfo(searchableInfo);
        // Perform the search
        searchView.setOnQueryTextListener(new OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(final String query) {
                // Open the search activity
                NavUtils.openSearch(BaseActivity.this, query);
                return true;
            }

            @Override
            public boolean onQueryTextChange(final String newText) {
                // Nothing to do
                return false;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : OnQueryTextListener(android.support.v7.widget.SearchView.OnQueryTextListener) SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) SearchableInfo(android.app.SearchableInfo)

Example 5 with OnQueryTextListener

use of android.support.v7.widget.SearchView.OnQueryTextListener in project bitcoin-wallet by bitcoin-wallet.

the class ExchangeRatesFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    inflater.inflate(R.menu.exchange_rates_fragment_options, menu);
    final MenuItem searchMenuItem = menu.findItem(R.id.exchange_rates_options_search);
    if (Constants.ENABLE_EXCHANGE_RATES) {
        final SearchView searchView = (SearchView) searchMenuItem.getActionView();
        searchView.setOnQueryTextListener(new OnQueryTextListener() {

            @Override
            public boolean onQueryTextChange(final String newText) {
                query = Strings.emptyToNull(newText.trim());
                getLoaderManager().restartLoader(ID_RATE_LOADER, null, rateLoaderCallbacks);
                return true;
            }

            @Override
            public boolean onQueryTextSubmit(final String query) {
                searchView.clearFocus();
                return true;
            }
        });
        // Workaround for not being able to style the SearchView
        final int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
        final View searchInput = searchView.findViewById(id);
        if (searchInput instanceof EditText)
            ((EditText) searchInput).setTextColor(Color.WHITE);
    } else {
        searchMenuItem.setVisible(false);
    }
    super.onCreateOptionsMenu(menu, inflater);
}
Also used : EditText(android.widget.EditText) OnQueryTextListener(android.widget.SearchView.OnQueryTextListener) SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Aggregations

SearchView (android.support.v7.widget.SearchView)5 OnQueryTextListener (android.support.v7.widget.SearchView.OnQueryTextListener)5 MenuItem (android.view.MenuItem)3 SearchManager (android.app.SearchManager)2 SearchableInfo (android.app.SearchableInfo)2 Bundle (android.os.Bundle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 MenuInflater (android.view.MenuInflater)1 View (android.view.View)1 EditText (android.widget.EditText)1 SearchView (android.widget.SearchView)1 OnQueryTextListener (android.widget.SearchView.OnQueryTextListener)1 TextView (android.widget.TextView)1