Search in sources :

Example 26 with SearchView

use of androidx.appcompat.widget.SearchView in project Rajawali by Rajawali.

the class ExamplesFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem menuItemSearch = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) menuItemSearch.getActionView();
    searchView.setOnQueryTextListener(this);
}
Also used : SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Example 27 with SearchView

use of androidx.appcompat.widget.SearchView in project collect by opendatakit.

the class SelectMinimalDialog method initSearchBar.

private void initSearchBar() {
    getToolbar().inflateMenu(R.menu.select_minimal_dialog_menu);
    SearchView searchView = (SearchView) getToolbar().getMenu().findItem(R.id.menu_filter).getActionView();
    searchView.setQueryHint(getResources().getString(R.string.search));
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.onActionViewExpanded();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchView.clearFocus();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            viewModel.getSelectListAdapter().getFilter().filter(newText);
            return false;
        }
    });
}
Also used : SearchView(androidx.appcompat.widget.SearchView)

Example 28 with SearchView

use of androidx.appcompat.widget.SearchView in project collect by opendatakit.

the class AppListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
    inflater.inflate(R.menu.list_menu, menu);
    final MenuItem sortItem = menu.findItem(R.id.menu_sort);
    final MenuItem searchItem = menu.findItem(R.id.menu_filter);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getResources().getString(R.string.search));
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            filterText = query;
            updateAdapter();
            searchView.clearFocus();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            filterText = newText;
            updateAdapter();
            return false;
        }
    });
    MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            sortItem.setVisible(false);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            sortItem.setVisible(true);
            return true;
        }
    });
}
Also used : MenuItemCompat(androidx.core.view.MenuItemCompat) SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Example 29 with SearchView

use of androidx.appcompat.widget.SearchView in project MovieGuide by esoxjem.

the class MoviesListingActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) searchItem.getActionView();
    final MoviesListingFragment mlFragment = (MoviesListingFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_listing);
    searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            MoviesListingFragment mlFragment = (MoviesListingFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_listing);
            mlFragment.searchViewBackButtonClicked();
            return true;
        }
    });
    searchViewTextSubscription = RxSearchView.queryTextChanges(searchView).debounce(500, TimeUnit.MILLISECONDS).subscribe(charSequence -> {
        if (charSequence.length() > 0) {
            mlFragment.searchViewClicked(charSequence.toString());
        }
    });
    return true;
}
Also used : MovieDetailsActivity(com.esoxjem.movieguide.details.MovieDetailsActivity) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) Intent(android.content.Intent) SearchView(androidx.appcompat.widget.SearchView) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) MenuItem(android.view.MenuItem) TimeUnit(java.util.concurrent.TimeUnit) Disposable(io.reactivex.disposables.Disposable) MovieDetailsFragment(com.esoxjem.movieguide.details.MovieDetailsFragment) Menu(android.view.Menu) IdlingResource(androidx.test.espresso.IdlingResource) Toolbar(androidx.appcompat.widget.Toolbar) EspressoIdlingResource(com.esoxjem.movieguide.util.EspressoIdlingResource) Constants(com.esoxjem.movieguide.Constants) RxUtils(com.esoxjem.movieguide.util.RxUtils) R(com.esoxjem.movieguide.R) VisibleForTesting(androidx.annotation.VisibleForTesting) Movie(com.esoxjem.movieguide.Movie) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Example 30 with SearchView

use of androidx.appcompat.widget.SearchView in project Signal-Android by signalapp.

the class CameraContactSelectionFragment method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(@NonNull Menu menu) {
    requireActivity().getMenuInflater().inflate(R.menu.camera_contacts, menu);
    MenuItem searchViewItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchViewItem.getActionView();
    SearchView.OnQueryTextListener queryListener = new SearchView.OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String query) {
            contactViewModel.onQueryUpdated(query);
            return true;
        }
    };
    searchViewItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            searchView.setOnQueryTextListener(queryListener);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            searchView.setOnQueryTextListener(null);
            contactViewModel.onSearchClosed();
            return true;
        }
    });
}
Also used : SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Aggregations

SearchView (androidx.appcompat.widget.SearchView)39 MenuItem (android.view.MenuItem)29 View (android.view.View)7 Bundle (android.os.Bundle)5 SearchManager (android.app.SearchManager)4 Intent (android.content.Intent)4 Drawable (android.graphics.drawable.Drawable)4 SpannableString (android.text.SpannableString)4 MenuInflater (android.view.MenuInflater)4 LinearLayout (android.widget.LinearLayout)4 TextView (android.widget.TextView)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 Activity (android.app.Activity)3 Context (android.content.Context)3 Uri (android.net.Uri)3 Handler (android.os.Handler)3 Menu (android.view.Menu)3 ViewTreeObserver (android.view.ViewTreeObserver)3