Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active Apr 4, 2017
Embed
What would you like to do?
filter
mealListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View dialogView, int position, long id) {
TextView mealName = (TextView) getActivity().findViewById(R.id.meal_name_text);
mealName.setText(adapter.getItem(position).getName());
TextView mealId = (TextView) getActivity().findViewById(R.id.meal_name_id);
mealId.setText(String.valueOf(adapter.getItem(position).getId()));
MealPickerFragment.this.dismiss();
}
});
EditText filterEditText = (EditText) view.findViewById(R.id.meal_name_filter);
filterEditText.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) {
Filter filter = adapter.getFilter();
filter.filter(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment