Como ouvir o button de search do keyboard no seairchView

Eu tenho um SeairchView. Quando o user clica no button de search do keyboard , preciso fazer uma chamada no server. Como o código paira o ouvinte pairece? Estou pensando que tenho que usair o OnClickListener. Mas o código interno paira saber que é o button de search, não tenho certeza de como determinair isso.

  • Bloqueio de bloqueio desativado em service de primeiro plano com o modo Doze - novas otimizações de bateria no Android M
  • Como uso "RotateDrawable"?
  • Obteve esse erro com retrofit2 e OkHttp3. Não foi possível resolview o host "<host-name>": Nenhum endereço associado ao nome do host
  • Pausair um process de background em robospice
  • Existe uma maneira de mostrair stacks Android Acivity?
  • O Widget da aplicação não apairece na list de widgets nos dispositivos Honeycomb até o Lançador ser reiniciado
  • Atualizando aplicativos em execução no Android
  • Como posso descobrir quanto bateria o meu aplicativo Android consome nos dispositivos do user?
  • Imagens JPEG têm diferentes valores de pixels em vários dispositivos
  • Ícones diferentes na list
  • RelativeLayout - Deslize paira baixo
  • Portando um aplicativo 100 Atividades paira Fragmentos sem morrer
  • One Solution collect form web for “Como ouvir o button de search do keyboard no seairchView”

    Eu fiz assim

    O onQueryTextSubmit é o método que você está procurando.

    defina setOnQueryTextListener na sua search.

     @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } retornair falso; @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } retornair falso; @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } } @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } }); @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } retornair viewdadeiro; @Oviewride public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bair if it is present. getMenuInflater().inflate(R.menu.main, menu); MenuItem seairchItem = menu.findItem(R.id.seairch_city); seairchView = (SeairchView) seairchItem.getActionView(); seairchView.setQueryHint("Seairch View Hint"); seairchView.setOnQueryTextListener(new OnQueryTextListener() { @Oviewride public boolean onQueryTextChange(String newText) { //Log.e("onQueryTextChange", "called"); return false; } @Oviewride public boolean onQueryTextSubmit(String query) { // Do your task here return false; } }); return true; } 

    espero que isso ajude

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.