1

I was trying to get the input connection of a SearchView. I wanna do this b/c i have an in app keyboard and whenever the user wants to search i will display my in app keyboard. For that purpose i am supposed to get the input connection of the SearchView using the method onCreateInputConnection, however the method is returning null for the SearchView, but it’s working fine for EditText. Also, i am using the SearchView on the navigation bar as a menu item.

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.options_menu_advanced_search, menu);
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        CustomAmharicKeyboard customAmharicKeyboard = findViewById(R.id.keyboard);
        customAmharicKeyboard.setVisibility(View.VISIBLE);
        InputConnection inputConnection = searchView.onCreateInputConnection(new EditorInfo());
        customAmharicKeyboard.setInputConnection(inputConnection);
    }  
FT Man
  • 11
  • 3

1 Answers1

1

SearchView does not extends EditText in fact it is a layout which holds multiple views. If you want to get InputConnection from SearchView you can try this

 InputConnection inputConnection = searchView.findViewById(R.id.search_src_text).onCreateInputConnection(new EditorInfo());