Example usage for android.support.v4.view MenuItem getItemId

List of usage examples for android.support.v4.view MenuItem getItemId

Introduction

In this page you can find the example usage for android.support.v4.view MenuItem getItemId.

Prototype

public int getItemId();

Source Link

Document

Return the identifier for this menu item.

Usage

From source file:com.chrulri.droidoflife.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.mi_automatic:
        // toggle automatic mode
        if (iterationTask == null) {
            iterationTask = new IterationTask();
            iterationTask.execute();//from  w  w  w. j  av  a2  s . c o m
        } else {
            iterationTask.cancel(false);
            iterationTask = null;
        }
        refreshTitle();
        return true;
    case R.id.mi_restart:
        // restart game of life
        restartRuntime();
        doRender();
        return true;
    case R.id.mi_settings:
        // open settings activity
        startActivityForResult(new Intent(this, SettingsActivity.class), RESULT_SETTINGS);
        return true;
    case R.id.mi_help:
        // open help dialog
        DialogFragment help = new HelpDialogFragment();
        help.show(getSupportFragmentManager(), null);
        return true;
    case R.id.mi_about:
        // open about dialog
        DialogFragment about = new AboutDialogFragment();
        about.show(getSupportFragmentManager(), null);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.ushahidi.android.app.ui.phone.ViewReportActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();/*from  w ww .  ja v  a 2 s.com*/
        return true;
    } else if (item.getItemId() == R.id.menu_forward) {

        if (report != null) {
            position++;
            if (!(position > (report.size() - 1))) {
                initReport(position);
                view.goNext();
            } else {
                position = report.size() - 1;
            }
        }
        return true;

    } else if (item.getItemId() == R.id.menu_backward) {

        if (report != null) {
            position--;
            if ((position < (report.size() - 1)) && (position != -1)) {
                initReport(position);
                view.goPrevious();
            } else {
                position = 0;
            }
        }
        return true;

    } else if (item.getItemId() == R.id.menu_share) {
        share();
    } else if (item.getItemId() == R.id.menu_comment) {
        Intent i = new Intent(ViewReportActivity.this, AddCommentActivity.class);

        i.putExtra("reportid", reportId);
        startActivityForResult(i, 0);
        overridePendingTransition(R.anim.home_enter, R.anim.home_exit);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.camera:
        Intent intent = new Intent(this, CameraSample.class);
        intent.putExtra("theme", mThemeId);
        startActivity(intent);/*from   w  w w  .  j  ava  2  s.  c o m*/
        return true;

    case R.id.toggleTitles:
        toggleVisibleTitles();
        return true;

    case R.id.toggleTheme:
        if (mThemeId == R.style.AppTheme_Dark) {
            mThemeId = R.style.AppTheme_Light;
        } else {
            mThemeId = R.style.AppTheme_Dark;
        }
        this.recreate();
        return true;

    case R.id.showDialog:
        showDialog("This is indeed an awesome dialog.");
        return true;

    case R.id.showStandardNotification:
        showNotification(false);
        return true;

    case R.id.showCustomNotification:
        showNotification(true);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.trosnoth.serveradmin.GameStateActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case android.R.id.home:
        Intent intent = new Intent(this, DashboardActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//  w w  w .  j  a va 2s.c  o  m
        return true;

    case R.id.refresh:
        update();
        Toast.makeText(this, "You feel refreshed.", Toast.LENGTH_SHORT).show();
        return true;

    default:
        Log.i(LOGTAG, "Option selection fell through.");
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.flipzu.flipzu.Profile.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Profile.this.finish();
        return true;
    case MENU_ITEM_LOGOUT:
        logoutProfile();/*w ww. j a  va 2  s  .  c o m*/
        return true;
    case MENU_ITEM_ABOUT:
        showAbout();
        return true;
    case MENU_ITEM_FOLLOW:
        followUnfollow();
        return true;
    case MENU_ITEM_SHARE:
        share();
        return true;
    case MENU_ITEM_SHARE_FLIPZU:
        shareFlipzu();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:org.pixmob.droidlink.ui.EventDetailsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.string.call:
        onCallNumber();/*  w  ww .ja  v a 2  s.c om*/
        return true;
    case R.string.compose_sms:
        onComposeSMS();
        return true;
    case R.string.delete_event:
        onConfirmDeleteEvent();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.chess.genesis.activity.GameListOnlineFrag.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.new_game:
        new NewOnlineGameDialog(act, handle).show();
        break;//from   w  w  w.  ja va 2  s  .  com
    case R.id.resync:
        resyncList();
        break;
    case R.id.readall_msgs:
        new ReadAllMsgsDialog(act, handle).show();
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:org.trosnoth.serveradmin.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case android.R.id.home:
        Intent intent = new Intent(this, DashboardActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//from   w  ww.  ja va 2 s. com
        return true;

    case R.id.players:
        playerDrawer.animateToggle();
        return true;

    case R.id.refresh:
        update();
        Toast.makeText(this, "You feel refreshed.", Toast.LENGTH_SHORT).show();
        return true;

    default:
        Log.i(LOGTAG, "Option selection fell through.");
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.todoroo.astrid.actfm.TagUpdatesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle my own menus
    switch (item.getItemId()) {

    case MENU_REFRESH_ID: {

        refreshActivity(true);//w  ww.j av  a 2 s.  c o m
        return true;
    }

    default:
        return false;
    }
}

From source file:com.ushahidi.android.app.ui.tablet.ListCheckinFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_refresh_checkin) {
        refresh = item;//from w  w  w.j ava  2 s . c om
        fetchCheckins();
        return true;
    } else if (item.getItemId() == R.id.menu_add_checkin) {
        launchAddCheckin(0);
        return true;
    } else if (item.getItemId() == R.id.menu_filter_by_users) {
        showDropDownNav();
        return true;
    } else if (item.getItemId() == android.R.id.home) {
        getActivity().finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}