Search in sources :

Example 56 with SearchView

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

the class Friends 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 friends");
        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 57 with SearchView

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

the class FollowedPeople 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 people");
        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 58 with SearchView

use of android.widget.SearchView in project robolectric by robolectric.

the class ShadowActivityTest method canGetOptionsMenuWithActionMenu.

@Test
public void canGetOptionsMenuWithActionMenu() throws Exception {
    ActionMenuActivity activity = buildActivity(ActionMenuActivity.class).create().visible().get();
    SearchView searchView = activity.mSearchView;
    // This blows up when ShadowPopupMenu existed.
    searchView.setIconifiedByDefault(false);
}
Also used : SearchView(android.widget.SearchView) Test(org.junit.Test)

Example 59 with SearchView

use of android.widget.SearchView in project ETSMobile-Android2 by ApplETS.

the class MapActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_map, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_map_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // Do not iconify the widget;
    searchView.setIconifiedByDefault(false);
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 60 with SearchView

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

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)

Aggregations

SearchView (android.widget.SearchView)72 View (android.view.View)37 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)28 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)12 SearchManager (android.app.SearchManager)11 Test (org.junit.Test)8 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 SettingsActivity (com.android.settings.SettingsActivity)7 MenuInflater (android.view.MenuInflater)6 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)4 Nullable (android.support.annotation.Nullable)3