Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active May 17, 2017 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/6b62c8711f18036e37dd5401c33d31b9 to your computer and use it in GitHub Desktop.
Save jezinka/6b62c8711f18036e37dd5401c33d31b9 to your computer and use it in GitHub Desktop.
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