Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active May 17, 2017
Embed
What would you like to do?
final EditText filterEditText = (EditText) addIngredientView.findViewById(R.id.name_filter);
filterEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Filter filter = ingredientListAdapter.getFilter();
filter.filter(s, new Filter.FilterListener() {
@Override
public void onFilterComplete(int count) {
int icon = count == 0 ? android.R.drawable.ic_menu_add : 0;
filterEditText.setCompoundDrawablesWithIntrinsicBounds(0, 0, icon, 0);
}
});
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment