onQueryTextSubmit in SearchView is performed twice Android Java



  • Hello, everyone!

    Such a problem, method onQueryTextSubmit Total SearchView Doing twice and only one time, what's the problem?

    Here's my code:

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                if (query != null)
                    audioRequest(query);
                return false;
            }
    
        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return true;
    

    }



  • Try this:

    if (query != null){
        searchView.clearFocus(); 
        audioRequest(query);
    }
        return false;
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2