Search in sources :

Example 16 with SearchView

use of androidx.appcompat.widget.SearchView 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(androidx.appcompat.widget.SearchView.OnQueryTextListener) SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Example 17 with SearchView

use of androidx.appcompat.widget.SearchView in project MaxLock by Maxr1998.

the class AppListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.applist_menu, menu);
    super.onCreateOptionsMenu(menu, inflater);
    menu.setGroupVisible(R.id.menu_group_default, false);
    final SearchView searchView = (SearchView) menu.findItem(R.id.toolbar_search).getActionView();
    searchView.setOnSearchClickListener(v -> menu.setGroupVisible(R.id.menu_group_hide_on_search, false));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            Util.hideKeyboardFromWindow(getActivity(), searchView);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            appListModel.getAdapter().getFilter().filter(s);
            return true;
        }
    });
    searchView.setOnCloseListener(() -> {
        menu.setGroupVisible(R.id.menu_group_hide_on_search, true);
        return false;
    });
    filterIcon(menu.findItem(R.id.toolbar_filter_activated));
    menu.findItem(R.id.toolbar_load_all).setTitle(appListModel.getLoadAll() ? R.string.menu_only_openable : R.string.menu_all_apps);
}
Also used : SearchView(androidx.appcompat.widget.SearchView)

Example 18 with SearchView

use of androidx.appcompat.widget.SearchView in project RxBinding by JakeWharton.

the class RxSearchViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    searchView = new SearchView(this);
    setContentView(searchView);
}
Also used : SearchView(androidx.appcompat.widget.SearchView)

Example 19 with SearchView

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

the class SubmitDebugLogActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.submit_debug_log_normal, menu);
    this.editMenuItem = menu.findItem(R.id.menu_edit_log);
    this.doneMenuItem = menu.findItem(R.id.menu_done_editing_log);
    this.searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    SearchView.OnQueryTextListener queryListener = new SearchView.OnQueryTextListener() {

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

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

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

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

Example 20 with SearchView

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

the class OnlineSearchFragment method setupToolbar.

private void setupToolbar(Toolbar toolbar) {
    toolbar.inflateMenu(R.menu.online_search);
    toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
    MenuItem searchItem = toolbar.getMenu().findItem(R.id.action_search);
    final SearchView sv = (SearchView) searchItem.getActionView();
    sv.setQueryHint(getString(R.string.search_podcast_hint));
    sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    sv.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
        if (hasFocus) {
            showInputMethod(view.findFocus());
        }
    });
    searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            getActivity().getSupportFragmentManager().popBackStack();
            return true;
        }
    });
    searchItem.expandActionView();
    if (getArguments().getString(ARG_QUERY, null) != null) {
        sv.setQuery(getArguments().getString(ARG_QUERY, null), 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