In this code the filter is working until the first word. From the moment I type the space character the filter stops working. Example: Search for "Steve Jobs", the system gets lost. Now if you search only until "Steve" it returns right.
ArrayList<> dados = new ArrayList<>();
SQLiteDatabase db1 = base.getReadableDatabase();
Cursor c = db1.rawQuery("SELECT * FROM produtos WHERE pcodgrupo LIKE '2' ORDER BY pcodprod ",null);
while (c.moveToNext())
{
HashMap map = new HashMap();
map.put("pcodprod", c.getString(0));
map.put("pdescricao", c.getString(2));
map.put("compl", c.getString(5));
map.put("pprecovenda", c.getString(9));
map.put("plocalizacaoprod", c.getString(25));
map.put("pprecoprazo", c.getString(c.getColumnIndex("pprecoprazo")));
dados.add(map);
}
String[] from = new String[]{"pcodprod", "plocalizacaoprod", "pdescricao", "compl", "pprecovenda","pprecoprazo"};
int layout = R.layout.list_teste_item2;
int[] to = new int[]{R.id.id, R.id.localP, R.id.nome, R.id.comple, R.id.prevoAv, R.id.precoPrazo};
ListView lv = (ListView) findViewById(R.id.listView2);
adapter = new SimpleAdapter(this, dados, layout, from, to);
lv.setAdapter(adapter);
edtPesquisa.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s.toString().trim());
}
@Override
public void afterTextChanged(Editable s) {
}