OnCloseListener do SearchView não funciona
Estou tentando adicionar suporte para oSearchView
na ActionBar do Android 3.0+, mas não consigo obter oOnCloseListener
trabalhar
Aqui está o meu código:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
searchView = (SearchView) menu.findItem(R.id.search_textbox).getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
searchLibrary(newText);
return false;
}
@Override
public boolean onQueryTextSubmit(String query) { return false; }
});
searchView.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
System.out.println("Testing. 1, 2, 3...");
return false;
}
});
return true;
}
A pesquisa funciona muito bem e tudo está funcionando, exceto oOnCloseListener
. Nada está sendo impresso no Logcat. Aqui está o Logcat para quando estou pressionando o botão "Fechar":
02-17 13:01:52.914: I/TextType(446): TextType = 0x0
02-17 13:01:57.344: I/TextType(446): TextType = 0x0
02-17 13:02:02.944: I/TextType(446): TextType = 0x0
Eu olhei atravésa documentaçã e amostras, mas nada parecia mudar isso. Estou rodando em um Asus Transformer Prime e um Galaxy Nexus, ambos no Ice Cream Sandwich. Alguma ideia
Atualizar
Sim -System.out.println()
fa trabalhos. Aqui está a prova:
@Override
public boolean onQueryTextChange(String newText) {
System.out.println(newText + "hello");
searchLibrary(newText);
return false;
}
Resultados neste Logcat:
02-17 13:04:20.094: I/System.out(21152): hello
02-17 13:04:24.914: I/System.out(21152): thello
02-17 13:04:25.394: I/System.out(21152): tehello
02-17 13:04:25.784: I/System.out(21152): teshello
02-17 13:04:26.064: I/System.out(21152): testhello