Example usage for android.widget SearchView onActionViewExpanded

List of usage examples for android.widget SearchView onActionViewExpanded

Introduction

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

Prototype

@Override
public void onActionViewExpanded() 

Source Link

Usage

From source file:in.rab.ordboken.Ordboken.java

public SearchView initSearchView(Activity activity, Menu menu, String query, Boolean focus) {
    SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) activity.findViewById(R.id.mySearchView);

    searchView.setSearchableInfo(//  w  w  w. j  a  v  a2  s .  c o  m
            searchManager.getSearchableInfo(new ComponentName(activity, MainActivity.class)));

    // Hack to get the magnifying glass icon inside the EditText
    searchView.setIconifiedByDefault(true);
    searchView.setIconified(false);

    // Hack to get rid of the collapse button
    searchView.onActionViewExpanded();

    if (!focus) {
        searchView.clearFocus();
    }

    // searchView.setSubmitButtonEnabled(true);
    searchView.setQueryRefinementEnabled(true);

    if (query != null) {
        searchView.setQuery(query, false);
    }

    return searchView;
}