Example usage for android.view MenuItem getItemId

List of usage examples for android.view MenuItem getItemId

Introduction

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

Prototype

public int getItemId();

Source Link

Document

Return the identifier for this menu item.

Usage

From source file:ca.liquidlabs.android.speedtestvisualizer.activities.MapperActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        ////from   w  w  w  .j a  v a 2 s.c o m
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:eu.codeplumbers.cosi.activities.ExpenseDetailsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_save_expense) {
        saveExpenseAndSync();/*from   www. j  a v  a2s .c o m*/
        return true;
    }
    if (id == R.id.action_delete_expense) {
        deleteExpenseAndSync();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.deliciousdroid.fragment.AddBookmarkFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.menu_addbookmark_save:
        save();/*from   ww  w.  j a va 2  s.c  om*/
        bookmarkSaveListener.onBookmarkSave(bookmark);
        return true;
    case R.id.menu_addbookmark_cancel:
        bookmarkSaveListener.onBookmarkCancel(bookmark);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:pl.bcichecki.rms.client.android.activities.LoginActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.activity_login_menu_remind_password) {
        Log.d(TAG, "Showing Remind Password Dialog...");

        RemindPasswordDialog remindPasswordDialog = new RemindPasswordDialog();
        remindPasswordDialog.show(getSupportFragmentManager(), TAG);
        return true;
    }/* w  w  w  . j  a  v a 2  s .  c om*/
    if (item.getItemId() == R.id.activity_login_menu_register) {
        Log.d(TAG, "Showing Register Dialog...");

        RegisterDialog registerDialog = new RegisterDialog();
        registerDialog.show(getSupportFragmentManager(), TAG);
        return true;
    }
    if (item.getItemId() == R.id.activity_login_menu_settings) {
        Log.d(TAG, "Moving to Settings Activity...");

        Intent settingsActivityIntent = new Intent(this, SettingsActivity.class);
        startActivity(settingsActivityIntent);
        return true;
    }
    if (item.getItemId() == R.id.activity_login_menu_about) {
        Log.d(TAG, "Showing about dialog...");

        AboutDialog aboutDialog = new AboutDialog();
        aboutDialog.show(getSupportFragmentManager(), TAG);
        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 ww  w  . ja va2s. c om
    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:com.application.treasurehunt.ScanQRCodeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case 1: {//from   www .ja v a  2  s  . c  o  m

        Intent homepageActivityIntent = new Intent(ScanQRCodeActivity.this, HomepageActivity.class);
        startActivity(homepageActivityIntent);

        return true;
    }
    case 2: {

        mEditor.clear();
        mEditor.commit();

        mMapManager.stopLocationUpdates();

        Intent loginActivityIntent = new Intent(ScanQRCodeActivity.this, LoginActivity.class);
        startActivity(loginActivityIntent);
    }
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.synchophy.ui.CoverFlowActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    Intent i = null;/*from   w w  w. j a  v a 2  s.  com*/

    switch (item.getItemId()) {

    case BrowseActivity.MAIN:
        i = new Intent(this, MainMenuActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);
        return true;
    case BrowseActivity.PLAYLIST:
        i = new Intent(this, PlaylistActivity.class);
        startActivityForResult(i, BrowseActivity.PLAYLIST);
        return true;
    case BrowseActivity.FILTER:
        PlayerManager.setFiltering(!PlayerManager.isFiltering());
        refresh();
        return true;
    }
    return false;
}

From source file:com.kaytat.simpleprotocolplayer.MainActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.notice_item:
        Intent intent = new Intent(this, NoticeActivity.class);
        startActivity(intent);// w  w  w  . j  a v  a2 s.c o  m
        return true;

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

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        exitGpms();/*  w w w.  j a  v a  2  s.  co m*/
        return true;
    case R.id.action_bug_report:
        Intent intent = new Intent(getApplicationContext(), BugReport.class);
        intent.putExtra("studentName", (studentName != null ? studentName : "Anonymous"));
        intent.putExtra("studentRollNo", (studentRollNo != null ? studentRollNo : "0"));
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.hackensack.umc.activity.ViewProfileActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {

    case android.R.id.home:
        isBackPressed = true;/*from   w  w  w.  j  ava2s  .co m*/
        finish();
        return true;

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