2
made a search
on my list however it needs me to click enter to complete the search and show the results. I would like the result to come automatically when typing. Thank you.
My code:
........
public class ListClientes extends AppCompatActivity implements AdapterView.OnItemLongClickListener, AdapterView.OnItemClickListener {
ListView lista;
ArrayList<Cliente> clientes;
EditText search;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_clientes);
lista = (ListView) findViewById(R.id.listview);
search = (EditText) findViewById(R.id.search);
lista.setOnItemLongClickListener(this);
lista.setOnItemClickListener(this);
atualizar(null);
search.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
atualizar(null);
return false;
}
});
}
public void atualizar(View view) {
ClienteDao cliDao = new ClienteDao();
clientes = cliDao.getListagem(" where nome like '" + search.getText().toString() + "%'");
lista.setAdapter(new ClienteAdapter(getBaseContext(), clientes));
}
........
maybe it doesn’t work because cell phones have no buttons, try to use the event
touch
– Brumazzi DB