Search in sources :

Example 41 with SearchView

use of android.widget.SearchView in project android_frameworks_base by DirtyUnicorns.

the class SelectPrinterActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.select_printer_activity, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String searchString) {
            ((DestinationAdapter) mListView.getAdapter()).getFilter().filter(searchString);
            return true;
        }
    });
    searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {

        @Override
        public void onViewAttachedToWindow(View view) {
            if (AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
                view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
            }
        }

        @Override
        public void onViewDetachedFromWindow(View view) {
            if (!isFinishing() && AccessibilityManager.getInstance(SelectPrinterActivity.this).isEnabled()) {
                view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
            }
        }
    });
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(android.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 42 with SearchView

use of android.widget.SearchView in project android_packages_apps_Settings by LineageOS.

the class PrintServiceSettingsFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.print_service_settings, menu);
    MenuItem addPrinters = menu.findItem(R.id.print_menu_item_add_printer);
    if (mServiceEnabled && mAddPrintersIntent != null) {
        addPrinters.setIntent(mAddPrintersIntent);
    } else {
        menu.removeItem(R.id.print_menu_item_add_printer);
    }
    MenuItem settings = menu.findItem(R.id.print_menu_item_settings);
    if (mServiceEnabled && mSettingsIntent != null) {
        settings.setIntent(mSettingsIntent);
    } else {
        menu.removeItem(R.id.print_menu_item_settings);
    }
    MenuItem searchItem = menu.findItem(R.id.print_menu_item_search);
    if (mServiceEnabled && mPrintersAdapter.getUnfilteredCount() > 0) {
        mSearchView = (SearchView) searchItem.getActionView();
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

            @Override
            public boolean onQueryTextChange(String searchString) {
                mPrintersAdapter.getFilter().filter(searchString);
                return true;
            }
        });
        mSearchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {

            @Override
            public void onViewAttachedToWindow(View view) {
                if (AccessibilityManager.getInstance(getActivity()).isEnabled()) {
                    view.announceForAccessibility(getString(R.string.print_search_box_shown_utterance));
                }
            }

            @Override
            public void onViewDetachedFromWindow(View view) {
                Activity activity = getActivity();
                if (activity != null && !activity.isFinishing() && AccessibilityManager.getInstance(activity).isEnabled()) {
                    view.announceForAccessibility(getString(R.string.print_search_box_hidden_utterance));
                }
            }
        });
    } else {
        menu.removeItem(R.id.print_menu_item_search);
    }
}
Also used : SearchView(android.widget.SearchView) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.widget.SearchView)

Example 43 with SearchView

use of android.widget.SearchView in project SEProject by NicholasBarreyre.

the class TeamActivity method onCreateOptionsMenu.

/**
 * Configures options menu
 *
 * @param menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_team, menu);
    MenuItem searchItem = menu.findItem(R.id.action_join_team);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setSearchableInfo(((SearchManager) getSystemService(Context.SEARCH_SERVICE)).getSearchableInfo(getComponentName()));
    searchView.onActionViewExpanded();
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem)

Example 44 with SearchView

use of android.widget.SearchView 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)

Example 45 with SearchView

use of android.widget.SearchView in project ShelterApp by farzamtn.

the class ShelterItemListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shelteritem_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(getTitle());
    // Show the Up button in the action bar.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    View recyclerView = findViewById(R.id.shelteritem_list);
    assert recyclerView != null;
    setupRecyclerView((RecyclerView) recyclerView);
    SearchView searchBar = (SearchView) findViewById(R.id.search_bar);
    searchBar.setQueryHint("Search Shelters");
    searchBar.setSubmitButtonEnabled(true);
    searchBar.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            if (query == null || query.equals("")) {
                setupRecyclerView((RecyclerView) recyclerView);
            }
            setupRecyclerView((RecyclerView) recyclerView, searchBar.getQuery());
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            if (query == null || query.equals("")) {
                setupRecyclerView((RecyclerView) recyclerView);
            }
            setupRecyclerView((RecyclerView) recyclerView, searchBar.getQuery());
            return true;
        }
    });
    if (findViewById(R.id.shelteritem_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;
    }
}
Also used : SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

SearchView (android.widget.SearchView)67 View (android.view.View)35 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)26 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 SearchManager (android.app.SearchManager)11 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 SettingsActivity (com.android.settings.SettingsActivity)7 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 MenuInflater (android.view.MenuInflater)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Nullable (android.support.annotation.Nullable)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)3