Best code examples for Android MenuItem class (android.view.MenuItem)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MenuItem class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android MenuItem examples from Open Source projects
This code example shows how to use the following methods: getItemId
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
    	// This passes the menu option string to OF 
    	// you can add additional behavior from java modifying this method 
    	// but keep the call to OFAndroid so OF is notified of menu events 
    	if(OFAndroid.menuItemSelected(item.getItemId())){
    		 
    		return true; 
    	} 
    	return super.onOptionsItemSelected(item);
    } 
     
 
    @Override 
    public boolean onPrepareOptionsMenu (Menu menu){
    	// This method is called every time the menu is opened 
    	//  you can add or remove menu options from here 
    	return  super.onPrepareOptionsMenu(menu);
    } 
	 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItemId, getMenuInfo
        .setIcon(R.drawable.delete).setAlphabeticShortcut('d');
  } 
 
  @Override 
  public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case DELETE_ID:
        AdapterView.AdapterContextMenuInfo info=
            (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
 
        delete(info.id);
        return(true); 
    } 
 
    return(super.onOptionsItemSelected(item));
  } 
 
  public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    return(new CursorLoader(this, Provider.Constants.CONTENT_URI,
                            PROJECTION, null, null, null));
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItemId
        return true; 
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                return true; 
            case MENU_OVERFLOW:
                mMenuDrawer.toggleMenu();
                return true; 
        } 
        return super.onOptionsItemSelected(item);
    } 
 
    /** 
     * Click handler for top drawer items. 
     */ 
    @Override 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItemId
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
    	// This passes the menu option string to OF 
    	// you can add additional behavior from java modifying this method 
    	// but keep the call to OFAndroid so OF is notified of menu events 
    	if(OFAndroid.menuItemSelected(item.getItemId())){
    		 
    		return true; 
    	} 
    	return super.onOptionsItemSelected(item);
    } 
     
 
    @Override 
    public boolean onPrepareOptionsMenu (Menu menu){
    	// This method is called every time the menu is opened 
    	//  you can add or remove menu options from here 
    	return  super.onPrepareOptionsMenu(menu);
    } 
	 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getItemId, getMenuInfo
        .setAlphabeticShortcut('d'); 
  } 
 
  @Override 
  public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case DELETE_ID:
        AdapterView.AdapterContextMenuInfo info=
          (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
 
        delete(info.id);
        return(true); 
    } 
 
    return(super.onOptionsItemSelected(item));
  } 
 
  public Loader<Cursor> onCreateLoader(int loaderId, Bundle args) {
    return(new CursorLoader(this, Provider.Constants.CONTENT_URI,
                            PROJECTION, null, null, null));
Full Snippet Info
8
CodeRank
Related Android MenuItem Questions & Answers:
Other Android MenuItem Examples
40:	
41:	  @Override
42:	  public boolean onOptionsItemSelected(MenuItem item) {
43:	    Toast.makeText(this, "Just a test", Toast.LENGTH_SHORT).show();
44:	    return true;

Read More

6:		 * */
7:		@Override
8:		public boolean onOptionsItemSelected(MenuItem item) {
9:			// Take appropriate action for each action item click
10:			switch (item.getItemId()) {

Read More

28:	     * */
29:	    @Override
30:	    public boolean onOptionsItemSelected(MenuItem item)
31:	    {
32:

Read More

24:	
25:		// Refresh menu item
26:		private MenuItem refreshMenuItem;
27:	
28:		@Override
-
43:		 * */
44:		@Override
45:		public boolean onOptionsItemSelected(MenuItem item) {
46:			// Take appropriate action for each action item click
47:			switch (item.getItemId()) {

Read More

1:	@Override
2:	public boolean onOptionsItemSelected(MenuItem item) {
3:	    switch (item.getItemId()) {
4:	        case R.id.vibrate:

Read More

1:	@Override
2:	public boolean onOptionsItemSelected(MenuItem item) {
3:	    // Handle item selection
4:	    switch (item.getItemId()) {

Read More

1:	@Override
2:	public boolean onContextItemSelected(MenuItem item) {
3:	    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
4:	    switch (item.getItemId()) {

Read More

See Code Examples for Android MenuItem Methods: