Skip to content

Instantly share code, notes, and snippets.

@exhesham
Created June 8, 2018 09:23
Show Gist options
  • Save exhesham/1688421cd46118dd0b2209546f9a8027 to your computer and use it in GitHub Desktop.
Save exhesham/1688421cd46118dd0b2209546f9a8027 to your computer and use it in GitHub Desktop.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// COMPLETED (9) Within onCreateOptionsMenu, use getMenuInflater().inflate to inflate the menu
getMenuInflater().inflate(R.menu.main, menu);
// COMPLETED (10) Return true to display your menu
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemThatWasClickedId = item.getItemId();
if (itemThatWasClickedId == R.id.action_search) {
Context context = MainActivity.this;
String textToShow = "Search clicked";
Toast.makeText(context, textToShow, Toast.LENGTH_SHORT).show();
return true;
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment