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:edu.nd.darts.cimon.NDroidAdmin.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.startup:
        SharedPreferences appPrefs = getSharedPreferences(SHARED_PREFS, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = appPrefs.edit();
        if (item.isChecked()) {
            item.setChecked(false);/*from  ww w .  ja v a2s . c  o m*/
            editor.putBoolean(PREF_STARTUP, false);
        } else {
            item.setChecked(true);
            editor.putBoolean(PREF_STARTUP, true);
        }
        editor.commit();
        return true;
    case R.id.exit:
        stopService(new Intent(this, NDroidService.class));
        if (DebugLog.DEBUG)
            Log.d(TAG, "CIMON service stopped - exiting");
        finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.spondbob.bluetooth.BluetoothActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_send:
        menuSend();//  w w  w  .  ja v a 2 s  . c o  m
        return true;
    case R.id.menu_discover:
        menuDiscover();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dcs.fakecurrencydetector.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.action_exit:
        finish();/*  ww w .  java  2 s .co m*/
        return true;
    case R.id.action_settings:
        //showSettings();
        return true;
    case R.id.action_about:
        showHelp();
        return true;
    case R.id.action_update:
        //showUpdate();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.skalski.raspberrycontrol.Activity_TempSensors.java

public boolean onOptionsItemSelected(MenuItem element) {
    switch (element.getItemId()) {
    case R.id.reconnect:
        if (client.isConnected()) {
            Log.w(LOGTAG, LOGPREFIX + "you are already connected to the server");
            toast_connection_error(getResources().getString(R.string.error_msg_5));
        } else {//from w  w  w  .ja  v a2  s.c o m
            if (!client.connect()) {
                Log.w(LOGTAG, LOGPREFIX + "can't connect to server - please try once again");
                toast_connection_error(getResources().getString(R.string.error_msg_4));
            } else {
                client.setFilter(TAG_TEMPSENSORS);
                client.setHandler(clientHandler);
                Log.i(LOGTAG, LOGPREFIX + "reconnecting to server");
            }
        }
        break;
    }
    return true;
}

From source file:net.carlh.toast.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        startActivity(new Intent(this, SettingsActivity.class));
        return true;
    } else if (id == R.id.action_timer) {
        pager.setCurrentItem(1);/* ww w.ja v a2 s .com*/
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.item_pause_on_scroll:
        pauseOnScroll = !pauseOnScroll;/*w  w w.ja va 2s.co m*/
        item.setChecked(pauseOnScroll);
        applyScrollListener();
        return true;
    case R.id.item_pause_on_fling:
        pauseOnFling = !pauseOnFling;
        item.setChecked(pauseOnFling);
        applyScrollListener();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.openhab.habdroid.ui.OpenHABStartupActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    //       case R.id.mainmenu_openhab_preferences:
    //            Intent myIntent = new Intent(this.getApplicationContext(), OpenHABPreferencesActivity.class);
    //            startActivityForResult(myIntent, 0);
    //          return true;
    case R.id.mainmenu_openhab_settings:
        Intent myIntent = new Intent(this.getApplicationContext(), OpenHABPreferencesActivity.class);
        startActivityForResult(myIntent, 0);
        return true;
    default://  w  ww.j a va2 s  . c om
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dvdprime.mobile.android.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();

    if (itemId == R.id.menu_setting) {
        EasyTracker.getTracker().sendEvent("Main Menu", "Click", "Setting", 0L);
        Intent i = new Intent(MainActivity.this, SettingActivity.class);
        startActivity(i);//www .j av  a  2s.c om
        return true;
    }

    if (itemId == R.id.menu_about) {
        EasyTracker.getTracker().sendEvent("Main Menu", "Click", "About", 0L);
        Intent i = new Intent(MainActivity.this, AboutActivity.class);
        startActivity(i);
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:gov.wa.wsdot.android.wsdot.ui.FlickrActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();/*from  ww w. j a  v  a  2  s . c  o m*/
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.pansapiens.occyd.NewPost.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent I;//from w ww  .ja  v a 2s  .  co m
    switch (item.getItemId()) {
    case 0:
        I = new Intent(this, Search.class);
        break;
    case 1:
        I = new Intent(this, NewPost.class);
        break;
    case 2:
        // if we launch the map, leave this NewPost activity
        // on the history stack (ie no call of this.finish() )
        // so that the back button brings us from the map back to here
        Toast.makeText(NewPost.this, "Finding location, mapping.", Toast.LENGTH_SHORT).show();
        I = new Intent(this, MapResults.class);
        startActivity(I);
        return true;
    case 3:
        startActivity(new Intent(this, Prefs.class));
        return true;
    case 4:
        //showAlert("Menu Item Clicked", "Help", "ok", null, false, null);
        return true;
    default:
        return false;
    }

    startActivity(I);
    this.finish();
    return true;
}