Example usage for android.widget SearchView setIconifiedByDefault

List of usage examples for android.widget SearchView setIconifiedByDefault

Introduction

In this page you can find the example usage for android.widget SearchView setIconifiedByDefault.

Prototype

public void setIconifiedByDefault(boolean iconified) 

Source Link

Document

Sets the default or resting state of the search field.

Usage

From source file:com.gnufabio.costituzione.SearchResultsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actionbar_mainscreen, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setOnQueryTextListener(this);

    return true;/*from www .  j  av a2  s .  co m*/
}

From source file:se.chalmers.watchme.activity.TagMovieListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    /*/*  w  w  w . java  2s . c o  m*/
     * It should not be possible to mail or sort in this activity
     */
    MenuItem mailItem = menu.findItem(R.id.menu_send_email_button);
    mailItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem sortItem = menu.findItem(R.id.menu_sort_button);
    sortItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    /*
     * Add necessary functionality for the search widget
     */
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search_button).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return true;
}

From source file:se.chalmers.watchme.activity.SearchableActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    /*//from  w w  w  .j  a  v a  2s . c  o  m
     * It should not be possible to mail or sort in this activity
     */
    MenuItem mailItem = menu.findItem(R.id.menu_send_email_button);
    mailItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem sortItem = menu.findItem(R.id.menu_sort_button);
    sortItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    /*
     * Add necessary functionality for the search widget
     */
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search_button).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return true;
}

From source file:com.bdenney.locl.activity.NearbyActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

    if (!TextUtils.isEmpty(getSearchTerm())) {
        final MenuItem item = menu.findItem(R.id.menu_search);
        if (item != null) {
            item.setVisible(false);// w ww  .  j a v a  2  s  .com
        }
    }

    return true;
}

From source file:com.jpuyo.barcelonaplaces.app.ui.activity.main.PlacesListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.placeslist_fragment, container, false);

    mApp = (BarcelonaPlacesApp) getActivity().getApplicationContext();

    mPlacesAdapter = new PlacesCursorCardAdapter(getActivity(), this);
    mPlacesAdapter.setPlaceDetailManager(mApp.getPlacesDetailManager());

    CardListView mListView = (CardListView) rootView.findViewById(R.id.cardlistview_placeslist_fragment);
    mListView.setAdapter(mPlacesAdapter);

    SearchView mSearchView = (SearchView) rootView.findViewById(R.id.searchview_place);
    mSearchView.setFocusable(true);/*from  ww  w.  j  a v a2s.  com*/
    mSearchView.setIconifiedByDefault(false);
    mSearchView.setOnQueryTextListener(this);

    return rootView;
}

From source file:se.chalmers.watchme.activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    mailItem = menu.findItem(R.id.menu_send_email_button);
    sortItem = menu.findItem(R.id.menu_sort_button);
    searchItem = menu.findItem(R.id.menu_search_button);

    setButtonsState();//from   w w w .j  a v  a2 s  .  co  m

    /*
     * Add necessary functionality for the search widget
     */
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search_button).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return true;
}

From source file:org.yuzhiqiang.itsmine.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (!mNavigationDrawerFragment.isDrawerOpen()) {
        // Only show items in the action bar relevant to this screen
        // if the drawer is not showing. Otherwise, let the drawer
        // decide what to show in the action bar.
        getMenuInflater().inflate(R.menu.main, menu);
        restoreActionBar();/*  ww w .ja  v  a 2  s.  c o  m*/

        // Get the SearchView and set the searchable configuration
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
        // Assumes current activity is the searchable activity
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.tinbytes.simplesearchapp.SimpleListViewActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_simple_list_view, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search_animal));
    if (searchView != null) {
        searchView.setOnQueryTextListener(this);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(true);
    }// w w  w .  jav  a  2s  .  c  om
    return true;
}

From source file:com.aboveware.actionbar.honeycomb.ActionBarHelperHoneycomb.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    mOptionsMenu = menu;/*from   w  w w .  j  av  a2 s  .c om*/
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    if (searchItem != null) {
        final SearchView searchView = (SearchView) searchItem.getActionView();
        searchView.setIconifiedByDefault(false);
        searchView.setSubmitButtonEnabled(true);
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String query) {
                return iDocument.searchSubmit(query);
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                return iDocument.search(newText);
            }
        });
    }
    boolean returnValue = super.onCreateOptionsMenu(menu);
    if (shouldBeRefreshing) {
        setRefreshActionItemState(true);
    }
    shouldBeRefreshing = false;
    return returnValue;
}

From source file:net.seedboxer.seedroid.activities.fragments.DownloadsFragment.java

/**
 * Get the SearchView and set the searchable configuration
 * @param menu//from w  w w  .j a  v a 2  s. c  o m
 */
private void createFilteredMenu(Menu menu) {
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        public boolean onQueryTextSubmit(String query) {
            adapter.getFilter().filter(query);
            return true;
        }

        public boolean onQueryTextChange(String newText) {
            adapter.getFilter().filter(newText);
            return true;
        }
    });
}