Guest User

Untitled

a guest
Aug 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. How do I set up a menu for my application?
  2. //Methods for menu
  3. // display the menu when menu botton clicked
  4.  
  5. @Override
  6. public boolean onCreateOptionsMenu(Menu menu) {
  7. super.onCreateOptionsMenu(menu);
  8. getMenuInflater().inflate(R.menu.lightmeter, menu);
  9. menu.findItem(R.id.about).setIntent(new Intent(this, about.class));
  10. menu.findItem(R.id.edit).setIntent(new Intent(this, menu.class));
  11. return true;
  12. }
  13.  
  14. //methods for menu
  15. //StartActivity for selecion
  16.  
  17. @Override
  18. public boolean onOptionsItemSelected(MenuItem item) {
  19. super.onOptionsItemSelected(item);
  20. startActivity(item.getIntent());
  21. return true;
  22. }
Add Comment
Please, Sign In to add comment