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:com.bringcommunications.etherpay.SendActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.show_gas: {
        boolean show_gas = item.isChecked() ? false : true;
        item.setChecked(show_gas);//from  www  .jav  a2s.  c o m
        SharedPreferences.Editor preferences_editor = preferences.edit();
        preferences_editor.putBoolean("show_gas", show_gas);
        preferences_editor.apply();
        recreate();
        return true;
    }
    case R.id.show_data: {
        boolean show_data = item.isChecked() ? false : true;
        item.setChecked(show_data);
        SharedPreferences.Editor preferences_editor = preferences.edit();
        preferences_editor.putBoolean("show_data", show_data);
        preferences_editor.apply();
        recreate();
        return true;
    }
    case R.id.help:
        do_help(R.string.send_help_title, R.string.send_help);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.romanenco.gitt.BrowserActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.browser_menu_delete:
        deleteThisRepo();/*from  w w w.j  a  v  a 2  s  .  co m*/
        break;
    case R.id.browser_switch_branch:
        Intent co = new Intent(this, CheckoutActivity.class);
        co.putExtra(CheckoutActivity.REPO, current);
        startActivity(co);
        break;
    case R.id.browser_menu_pull:
        pullFromOrigin();
        break;
    case R.id.browser_filter:
        showFilterBar(true);
        break;
    case R.id.browser_repo_log:
        Intent logView = new Intent(this, LogViewActivity.class);
        logView.putExtra(LogViewActivity.REPO, current);
        startActivity(logView);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.authorwjf.bounce.BluetoothChat.java

public boolean onOptionsItemSelected(MenuItem item) {
    Intent serverIntent = null;//from w  ww.  ja  v  a2  s  . c om
    switch (item.getItemId()) {
    case R.id.secure_connect_scan:
        // Launch the DeviceListActivity to see devices and do scan
        serverIntent = new Intent(this, DeviceListActivity.class);
        return true;
    case R.id.insecure_connect_scan:
        // Launch the DeviceListActivity to see devices and do scan
        serverIntent = new Intent(this, DeviceListActivity.class);
        return true;
    case R.id.discoverable:
        // Ensure this device is discoverable by others
        ensureDiscoverable();
        return true;
    }
    return false;
}

From source file:com.gigathinking.simpleapplock.ResetUnlockMethod.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();
    if (id == android.R.id.home) {
        finish();//from w ww.j av  a2 s .co  m
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.google.cloud.solutions.smashpix.MainActivity.java

  @Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.actionBarRefresh:
      listImages();/*  w  w  w. ja  v a  2 s  .  com*/
      break;
    case R.id.actionBarPicture:
      getPicture();
      break;
    case R.id.actionBarCamera:
      takePicture();
      break;
  }
  return true;
}

From source file:com.redhorse.quickstart.AppConfig.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case ITEM_ID_SETTING:
        break;/*w w w  .j a  v  a 2s .  c om*/
    case ITEM_ID_ABOUT:
        Intent setting = new Intent();
        setting.setClass(AppConfig.this, Feedback.class);
        startActivity(setting);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:rpi.rpiface.VoteActivity.java

/**
 * Se ejecuta cuando se pulsa un botn del menu
 * //from  ww w  . ja va  2 s .co m
 * @param item
 */
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        Intent intentPrefs = new Intent(this, PreferencesActivity.class);
        startActivity(intentPrefs);
        return true;
    case R.id.menu_exit:
        finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:jp.envision.android.cloudfingerpaint.CloudFingerPaint.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    mPaint.setXfermode(null);// w ww .  j  a  va  2  s  .co  m
    mPaint.setAlpha(0xFF);

    switch (item.getItemId()) {
    case COLOR_MENU_ID:
        new ColorPickerDialog(this, this, mPaint.getColor()).show();
        return true;
    case PRINT_MENU_ID:
        progressDialog = new ProgressDialog(this);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage("???s...");
        progressDialog.setCancelable(true);
        progressDialog.show();

        (new Thread(runnable)).start();

        return true;
    case EMBOSS_MENU_ID:
        if (mPaint.getMaskFilter() != mEmboss) {
            mPaint.setMaskFilter(mEmboss);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case BLUR_MENU_ID:
        if (mPaint.getMaskFilter() != mBlur) {
            mPaint.setMaskFilter(mBlur);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case ERASE_MENU_ID:
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
        return true;
    case SRCATOP_MENU_ID:
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
        mPaint.setAlpha(0x80);
        return true;
    case CLEAR_MENU_ID:
        Log.d(TAG, "Clear canvas.");
        myView.clear_all();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onOptionsItemSelected(MenuItem item)
 *//*  ww w.j  a v  a  2 s . c  o  m*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        serverList.refresh();
        lastRefresh = System.currentTimeMillis();
        return true;
    case R.id.menu_add_server:
        Intent addServer = new Intent(this, AddServerActivity.class);
        startActivityForResult(addServer, AddServerActivity.ADD_SERVER_ACTIVITY_ID);
        return true;
    case R.id.menu_search:
        InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        mgr.showSoftInput(getListView(), InputMethodManager.SHOW_FORCED);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.sakisds.icymonitor.activities.ConnectionActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.item_add:
        startActivity(new Intent(this, DetectServerActivity.class));
        return true;
    case R.id.item_settings:
        startActivity(new Intent(this, SettingsActivity.class));
        return true;
    case R.id.item_about:
        startActivity(new Intent(this, AboutActivity.class));
        return true;
    }/*from  w  w w  .j a v  a  2 s  . c o  m*/

    return super.onOptionsItemSelected(item);
}