Search code examples
androidandroid-actionbaractionbarsherlocksearchview

Can't disable Action Bar Sherlock's Search View from opening soft input keyboard


I'm using the Action Bar Sherlock SearchView in my UI. I have been trying to disable the opening of the soft input keyboard but it's not working. So far I have tried these methods.

  1. I used the input manager to disable the showing of the soft input keyboard.

    View target = this.getView().findFocus();
    if(target!=null)
    {
        InputMethodManager imm = (InputMethodManager)getSherlockActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(target.getWindowToken(), 0);
    }
    
  2. I set android:windowSoftInputMode="stateHidden" in the manifest's activity tag like so.

    <activity
            android:name=".ui.MainActivity"
            android:windowSoftInputMode="stateHidden"
            android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name"
            >
    

Nevertheless the keyboard is still popping up.

My SearchView implementation

 <com.actionbarsherlock.widget.SearchView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:iconifiedByDefault="false"
    android:layout_below="@+id/customView"
    android:id="@+id/searchView" android:layout_gravity="left|center_vertical"/>

    /* Code used to hide focus */
    searchView =(SearchView)view.findViewById(R.id.searchView);
    searchView.setFocusable(false);

Solution

  • I simply just used searchView.clearFocus() and that stopped the keyboard from popping up.