MaterialSearchBar
MaterialSearchBar copied to clipboard
Controlling the Arrow icon
Hi there! i've tried to reach the arrow icon by
implementing the listener: searchBar.setOnSearchActionListener(this);
and using
@Override
// public void onButtonClicked(int buttonCode)
can anyone tell me how i interact with the left arrow icon?
Add MaterialSearchBar.BUTTON_BACK as a case in your switch statement as show below.
public void onButtonClicked(int buttonCode) {
switch (buttonCode){
case MaterialSearchBar.BUTTON_NAVIGATION:
drawer.openDrawer(Gravity.LEFT);
break;
case MaterialSearchBar.BUTTON_SPEECH:
break;
case MaterialSearchBar.BUTTON_BACK:
searchBar.disableSearch();
break;
}
}
hey, i tried it and it didn't work, here's my code
searchBar = findViewById(R.id.searchBar); searchBar.setOnSearchActionListener(this);
@Override public void onButtonClicked(int buttonCode) {
switch (buttonCode){
case MaterialSearchBar.BUTTON_BACK:
Toast.makeText(this, "button back", Toast.LENGTH_SHORT).show();
searchPlaces();
break;
}
}
Exactly for me . It doesn't work , Same code .
It is not working for me as well. Need help!
You need to add this line in your xml:
app:mt_navIconEnabled="true"
You're welcome!
@cacato86 Hi, But i do not want hamburger icon on my search bar! What to do?