how to get the events of searchview in android

后端 未结 6 889
傲寒
傲寒 2020-12-15 04:58

I\'m using a search view in my application. Now i just want to get the text typed in the SearchView text box and display it on another textview. If i typed the text and clic

6条回答
  •  悲哀的现实
    2020-12-15 05:24

    Try to use setOnQueryTextListener of SearchView

    new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // your text view here
            textView.setText(newText);
            return true;
        }
    
        @Override
        public boolean onQueryTextSubmit(String query) {
            textView.setText(query);
            return true;
        }
    }
    

提交回复
热议问题