SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(Menus.SEARCH));
searchView.setQueryHint(this.getString(R.string.search));
editSearch = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
editSearch.setHintTextColor(getResources().getColor(R.color.white));
searchView.setOnQueryTextListener(OnQuerySearchView);
private OnQueryTextListener OnQuerySearchView = new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String newText) {
if (TextUtils.isEmpty(newText)) {
listAllContact.clearTextFilter();
} else {
listAllContact.setFilterText(newText.toString());
}
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
String text = editSearch.getText().toString()
.toLowerCase(Locale.getDefault());
adapter.filter(text);
return true;
}
};
MenuItemCompat.setOnActionExpandListener is now deprecated
use
menu.findItem(R.id.action_search)setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
return false;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
return false;
}
});
instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With