daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Aug 18th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top