Search code examples
androidandroid-softkeyboardsearchview

Is there an event when a SearchView is focused?


I'm using a SearchView to enter a number from a bluetooth barcode reader.

The SearchView is focused as follows:

svActListaPedidosFragmento.setFocusable(true);
svActListaPedidosFragmento.setIconified(false);

The search is done as follows:

  private SearchView.OnQueryTextListener svActListaPedidosFragmentoOnQueryTextListener = new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            //my code
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    };

The problem is that when the SearchView is focused, the software keyboard appears. Currently I know how to hide this keyboard, but I need an event that tells me that the SearchView has been focused.

I have read several examples, but none works.

Any comments or suggestions are welcome.


Solution

  • add OnClickListener to SearchView