MaterialSearchBar icon indicating copy to clipboard operation
MaterialSearchBar copied to clipboard

Controlling the Arrow icon

Open ghost opened this issue 6 years ago • 6 comments

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?

ghost avatar Oct 13 '17 13:10 ghost

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;
        }
    }
  

GitUser4732 avatar Oct 14 '17 04:10 GitUser4732

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;

    }
}

ghost avatar Oct 14 '17 10:10 ghost

Exactly for me . It doesn't work , Same code .

ghost avatar Feb 22 '18 11:02 ghost

It is not working for me as well. Need help!

rhlmshr avatar Jul 27 '18 12:07 rhlmshr

You need to add this line in your xml:

app:mt_navIconEnabled="true"

You're welcome!

cacato86 avatar Aug 08 '18 10:08 cacato86

@cacato86 Hi, But i do not want hamburger icon on my search bar! What to do?

yarodevuci avatar Jan 18 '19 02:01 yarodevuci