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.burntout.burntout.AddCarActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    switch (item.getItemId()) {

    case android.R.id.home:
        leaveme();//from  www . j  a v a 2 s .  c  om
        return true;

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

From source file:com.netpace.expressit.fragment.MainGridFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    case R.id.menu_item_media_upload:
        Intent intent = new Intent(getActivity(), MediaOptionsActivity.class);
        startActivity(intent);/*from   w  w w . j  ava 2 s  .  c  o m*/
        break;

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

From source file:net.reichholf.dreamdroid.activities.TimerListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case (MENU_RELOAD):
        reload();/*from ww  w.j  a  va  2s  .  c om*/
        return true;
    case (MENU_NEW_TIMER):
        mTimer = Timer.getInitialTimer();
        editTimer(mTimer, true);
        return true;
    case (MENU_CLEANUP):
        cleanupTimerList();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.miz.mizuu.fragments.CollectionCoverSearchFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        getActivity().onBackPressed();//from www. j  av a2  s.c om
        return true;
    }

    item.setChecked(true);

    if (item.getItemId() == 0) {
        mImageUrls.clear();
        for (int i = 0; i < mCovers.size(); i++)
            mImageUrls.add(mCovers.get(i).getUrl());
        if (mAdapter != null)
            ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged();
    } else {
        mImageUrls.clear();
        for (int i = 0; i < mCovers.size(); i++) {
            if (mCovers.get(i).getLanguage().equals(mItems[item.getItemId()])) {
                mImageUrls.add(mCovers.get(i).getUrl());
            }
        }
        if (mAdapter != null)
            ((BaseAdapter) mGridView.getAdapter()).notifyDataSetChanged();
    }

    return super.onOptionsItemSelected(item);
}

From source file:fr.bmartel.android.iotf.app.ConnectActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.disconnect_button:
        connect();//  w w w  . ja v a  2  s .  c om
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.example.qrpoll.PollActivity.java

@Override
/**/*  w  w  w .j  ava 2  s  .c o m*/
 * reagowanie na klikniecie na przyciski w menu
 */
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.historia) {
        Intent it = new Intent(getApplication(), HistoryLayout.class);
        startActivity(it);

        return true;
    } else if (id == R.id.odswiez) {

        refresh();
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.olejon.mdapp.ClinicalTrialsCardsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }// w  w w.j  a va2 s  . c om
    default: {
        return super.onOptionsItemSelected(item);
    }
    }
}

From source file:eu.cyberkat.h2owirelessbalancecheck.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_about:
        PackageInfo pInfo = null;/*from ww w .  j av  a 2s . com*/
        try {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (NameNotFoundException e) {
            pInfo = null;
        }
        if (pInfo == null) {
            return false;
        }
        String version = pInfo.versionName;
        int versionCode = pInfo.versionCode;
        Context aboutToastContext = getApplicationContext();
        CharSequence aboutToastText = "H2O Data Balance v" + version + ", (" + ordinal(versionCode)
                + " Revision)\nCopyright (c) 2014, Dylan J. Morrison <insidious@cyberkat.eu>, Licensed under the ISC license.";
        int aboutToastDuration = Toast.LENGTH_LONG;
        Toast aboutToast = Toast.makeText(aboutToastContext, aboutToastText, aboutToastDuration);
        aboutToast.show();
        return true;
    case R.id.action_grabnum:
        TelephonyManager tMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
        String mPhoneNumber = tMgr.getLine1Number();
        if (mPhoneNumber == null) {
            Context numberErrorContext = getApplicationContext();
            CharSequence numberErrorText = "Unable to get device phone number.";
            int numberErrorDuration = Toast.LENGTH_SHORT;
            Toast toast = Toast.makeText(numberErrorContext, numberErrorText, numberErrorDuration);
            toast.show();
        } else {
            EditText textbox = (EditText) this.findViewById(R.id.editText2);
            mPhoneNumber = mPhoneNumber.replaceAll("[^\\d]", "");
            textbox.setText(mPhoneNumber);
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.example.lidorcg.sunshine.ForecastFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_refresh) {
        FetchWeatherTask fetchWeather = new FetchWeatherTask();
        fetchWeather.execute("295620");
        return true;
    }/*from  w  w  w  . j ava 2 s  .  com*/
    return super.onOptionsItemSelected(item);
}

From source file:com.skalski.raspberrycontrol.Activity_Processes.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 {//  w  ww.ja va  2 s.com
            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_PROCESSES);
                client.setHandler(clientHandler);
                Log.i(LOGTAG, LOGPREFIX + "reconnecting to server");
            }
        }
        break;
    }
    return true;
}