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.lairdtech.lairdtoolkit.serialdevice.SerialActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.action_clear:
        mValueVspOutTv.setText("");
        mSerialManager.getVSPDevice().clearRxAndTxCounter();

        mValueRxCounterTv.setText("0");
        mValueTxCounterTv.setText("0");

        break;//from   ww  w.  j  a va 2s  .  c o m
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.example.parking.ParkingInformationActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from ww  w .  j  a v  a2  s  . co  m
        break;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.zoterodroid.activity.BrowseCitations.java

@Override
public boolean onContextItemSelected(MenuItem aItem) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) aItem.getMenuInfo();
    final Citation b = (Citation) lv.getItemAtPosition(menuInfo.position);

    switch (aItem.getItemId()) {
    case 0:// w  w w .  jav  a2  s .co m
        return true;

    case 1:
        return true;
    }
    return false;
}

From source file:com.glasshack.checkmymath.CheckMyMath.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle item selection.
    switch (item.getItemId()) {
    case R.id.stop:
        // Stop the service at the end of the message queue for proper options menu
        // animation. This is only needed when starting a new Activity or stopping a Service
        // that published a LiveCard.
        /*post(new Runnable() {
            @Override/*  w  w w  .  j  a va 2s. c om*/
            public void run() {
                stopService(new Intent(CheckMyMath.this, CheckMyMathService.class));
            }
        });*/
        return true;
    case R.id.takepicture:
        Log.e("WHOA", "about to take a pic");
        takePicture();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        if (launchedFromShortcut) {
            Intent i = new Intent(this, AppListActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);//from  w  w w  . j  a va  2 s.c  om
        }
        finish();
        return true;
    case R.id.action_fav:
        Utils.setFavorite(packageName, !Utils.isFavorite(packageName, this), this);
        invalidateOptionsMenu();
        break;
    case R.id.action_shortcut:
        createShortcut();
        Toast.makeText(this, R.string.toast_shortcut, Toast.LENGTH_SHORT).show();
        break;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.p2c.thelife.SettingsFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_logout) {
        // TODO make logout work
        //      new AlertDialog.Builder(getActivity())
        //          .setTitle(getResources().getString(R.string.logout_prompt))
        //          .setNegativeButton(R.string.cancel, null)
        //          .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
        ///*w  ww .j  a  v  a  2 s  . c  om*/
        //            @Override
        //            public void onClick(DialogInterface dialog, int which) {
        //
        //              // log out of app
        //              TheLifeConfiguration.getOwnerDS().setOwner(null);
        //
        //              // go to main screen
        //              Intent intent = new Intent("com.p2c.thelife.Initial");
        //              intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        //              startActivity(intent);
        //
        //            }
        //          }).show();
    } else if (item.getItemId() == R.id.action_help) {
        DrawerActivity activity = (DrawerActivity) getActivity();
        activity.showHelpDialog("Help", R.string.activity_settings_help);
    }

    return true;
}

From source file:com.hmsoft.bluetooth.le.DeviceControlActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) { //
    switch (item.getItemId()) {
    case R.id.menu_connect:
        mBluetoothLeService.connect(mDeviceAddress);
        return true;
    case R.id.menu_disconnect:
        mBluetoothLeService.disconnect();
        return true;
    case android.R.id.home:
        if (mConnected) {
            mBluetoothLeService.disconnect();
            mConnected = false;//from   ww w.j a v a  2s .  c o  m
        }
        onBackPressed();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.piusvelte.wapdroid.MapData.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case REFRESH_ID:
        mapData();//from  w w w .  ja va  2 s .  c o m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.grupohqh.carservices.operator.ReadTagActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }/* w  ww. j  av  a 2  s  .co  m*/

    return super.onOptionsItemSelected(item);
}

From source file:com.concentricsky.android.khanacademy.app.SignInActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//w w w.java  2 s . c  o m
        return true;
    case R.id.register:
        // Launch KA's registration page in the browser.
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_register))));
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}