Created
September 28, 2019 20:12
-
-
Save abhinavraj23/01643c1a3c4427c9b15e611f03e873b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchBar.setOnSearchActionListener(new SearchBar.OnSearchActionListener() { | |
@Override | |
public void onSearchStateChanged(boolean enabled) { | |
String state = enabled ? "enabled" : "disabled"; | |
Toast.makeText(getApplicationContext(), "Search bar is " + state, Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onSearchConfirmed(CharSequence text) { | |
Toast.makeText(getApplicationContext(), "Search query is: " + text, Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onButtonClicked(int buttonCode) { | |
switch (buttonCode) { | |
case SearchBar.BUTTON_BACK: | |
Toast.makeText(getApplicationContext(), "Back button pressed", Toast.LENGTH_SHORT).show(); | |
break; | |
case SearchBar.BUTTON_NAVIGATION: | |
Toast.makeText(getApplicationContext(), "Open Navigation Drawer", Toast.LENGTH_SHORT).show(); | |
break; | |
case SearchBar.BUTTON_SPEECH: | |
// Yet to come | |
Toast.makeText(getApplicationContext(), "Start voice recognition module", Toast.LENGTH_SHORT).show(); | |
break; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment