Search in sources :

Example 36 with SearchView

use of android.widget.SearchView in project Xposed-Tinted-Status-Bar by MohammadAG.

the class PackageListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    mSearchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    mSearchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem menuItem) {
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

                @Override
                public boolean onQueryTextSubmit(String query) {
                    mNameFilter = query;
                    mAppListAdaptor.getFilter().filter(mNameFilter);
                    findViewById(R.id.action_search).clearFocus();
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    mNameFilter = newText;
                    mAppListAdaptor.getFilter().filter(mNameFilter);
                    return false;
                }
            });
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem menuItem) {
            mAppListAdaptor.getFilter().filter("");
            return true;
        }
    });
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem)

Example 37 with SearchView

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

Example 38 with SearchView

use of android.widget.SearchView in project Klyph by jonathangerbaud.

the class Groups method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (getAdapter() != null && getAdapter().getCount() > 0) {
        // Create the search view
        SearchView searchView = new SearchView(((FragmentActivity) getActivity()).getActionBar().getThemedContext());
        searchView.setQueryHint("Search for groups");
        searchView.setOnQueryTextListener(this);
        menu.add("Search").setIcon(AttrUtil.getResourceId(getActivity(), R.attr.searchIcon)).setActionView(searchView).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    }
    super.onCreateOptionsMenu(menu, inflater);
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) SearchView(android.widget.SearchView)

Example 39 with SearchView

use of android.widget.SearchView in project k-9 by k9mail.

the class FolderList method configureFolderSearchView.

private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            mActionBarTitle.setText(getString(R.string.filter_folders_action));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });
    folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            mActionBarTitle.setText(getString(R.string.folders_title));
            return false;
        }
    });
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem)

Example 40 with SearchView

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

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)

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