// i am getting data from db in allShops
JsonArrayRequest jsonArrayRequest;
jsonArrayRequest = new JsonArrayRequest(url, new Response.Listener() {
@Override
public void onResponse(JSONArray response) {
for (int i = 0; i < response.length(); i++) {
try {
JSONObject jsonObject = response.getJSONObject(i);
//allShops is an arraylist
allShops.add(jsonObject.getString("name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
//user enters text in edittext et_search
et_search.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence cs, int start, int before, int count)
{
}
@Override
public void afterTextChanged(Editable s) {
//here i am adding arraylist to adapter but want it to happen after filtering the arraylist first based on users input
adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_list_item_1,allShops);
(Search.this).adapter.getFilter().filter(s);
lv_search.setAdapter(adapter);
}
});