Skip to content

Instantly share code, notes, and snippets.

@daichan4649
Created April 30, 2013 09:40
Show Gist options
  • Save daichan4649/5487690 to your computer and use it in GitHub Desktop.
Save daichan4649/5487690 to your computer and use it in GitHub Desktop.
show option menu (for Android)
// Fragment
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_search, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.search:
search();
return false;
default:
return super.onOptionsItemSelected(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment