Reputation: 975
I am using autocomplete text view in my app.But my requirement is When i am editing some letters in autocomplete text view by pressing back space button, i want to do some action at that time.I am using below code but its not working.
actv.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
//You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
if (keyCode == KeyEvent.KEYCODE_DEL) {
new RestaurantTask().execute("http://xxxx.co.in/xxxx_project/index.php/api/user/get_list/format/json",customerIdOnly);
}
return false;
}
});
Upvotes: 0
Views: 148
Reputation: 1969
Try this using textwatcher as follows. Hope it helps. thanks
actv.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// perform your tasks here like
adapter.notifyDataSetChanged();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
Upvotes: 1