androidkeyboardandroid-softkeyboardsearchviewsoft-keyboard

SearchView setIconified(false) automatically calls the focus for the searchview. How can I disable this?


I have the following code:

  if(mSearchView != null){
        mSearchView.setIconifiedByDefault(false);
        mSearchView.setIconified(false);
        mSearchView.setOnQueryTextListener(this);
        int searchPlateId = mSearchView.getContext().getResources()
                .getIdentifier("android:id/search_plate", null, null);
        View searchPlateView = mSearchView.findViewById(searchPlateId);
        if (searchPlateView != null) {
            searchPlateView.setBackgroundColor(getResources().getColor(R.color.white));
        }
    }

The problem is that the moment I setIconified(false) on the serachview, the keyboard pops up, and I do not want this to happen. Is it possible to prevent this somehow? PS: I Have this in the manifest:

 android:windowSoftInputMode="adjustNothing|stateHidden"

Also do it programmatically in onCreate but no luck


Solution

  • I used instead a edittext, and made the functionality of the search icon and close icon myself. This way, I do not have to set "setIconifiedByDefault" being a edittext. and it resolves all my issues