Example usage for android.widget SearchView setImeOptions

List of usage examples for android.widget SearchView setImeOptions

Introduction

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

Prototype

public void setImeOptions(int imeOptions) 

Source Link

Document

Sets the IME options on the query text field.

Usage

From source file:com.owncloud.android.ui.fragment.SearchShareesFragment.java

/**
 * {@inheritDoc}/*from ww w .  j  a v  a  2s .co  m*/
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);

    // Get the SearchView and set the searchable configuration
    SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()) // assumes parent activity is the searchable activity
    );
    searchView.setIconifiedByDefault(false); // do not iconify the widget; expand it by default

    searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // avoid fullscreen with softkeyboard

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
            return true; // return true to prevent the query is processed to be queried;
            // a user / group will be picked only if selected in the list of suggestions
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false; // let it for the parent listener in the hierarchy / default behaviour
        }
    });

    return view;
}