1

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);
Joel Dean
  • 2,444
  • 5
  • 32
  • 50
  • did you try this http://stackoverflow.com/questions/17645799/android-how-to-unfocus-a-searchview-programmatically – nandeesh Oct 20 '13 at 18:20

2 Answers2

1

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

Joel Dean
  • 2,444
  • 5
  • 32
  • 50
0

To disable any view (e.g. SearchView):

either set its input-type to "none" in XML or view.setInputType(InputType.TYPE_NULL) from the Activity

Deepti
  • 934
  • 12
  • 18