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.vishnuvalleru.travelweatheralertsystem.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_legalnotices:
        String LicenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();// ww  w .  j  a va  2 s .co m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.scigames.slidegame.ProfileActivity.java

/**
 * Called when a menu item is selected./*from   ww  w .  j  a  v  a 2 s .  c o m*/
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case BACK_ID:
        finish();
        return true;
    case QUIT_ID:
        finish();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:io.samsungsami.example.SAMInBLEws.SAMIDeviceActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_logout_sami:
        new LogoutSAMIInBackground().execute();
        return true;
    }//from w  ww .  j  av a  2  s  .  co m
    return super.onOptionsItemSelected(item);
}

From source file:com.royclarkson.springagram.GalleryPhotoListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.action_remove_from_gallery:
        removeFromGallery(info.position);
        return true;
    default://from  w  w  w  .ja  v  a 2  s .c o m
        return super.onContextItemSelected(item);
    }
}

From source file:net.networksaremadeofstring.rhybudd.DeviceList.java

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

    case R.id.search: {
        onSearchRequested();
        return true;
    }

    case R.id.refresh: {
        Refresh();
        return true;
    }

    }
    return false;
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection

    switch (item.getItemId()) {
    case R.id.action_refresh:
        getAccount();//from w w w .  j a v a  2s.  c  o m
    default:
        Log.d("Error!", "no action for that...");
    }
    return super.onOptionsItemSelected(item);
}

From source file:fr.cph.chicago.fragment.BikeFragment.java

@Override
public final boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mActivity);
        boolean loadBike = sharedPref.getBoolean("divvy_bike", true);
        if (loadBike) {
            MenuItem menuItem = item;
            menuItem.setActionView(R.layout.progressbar);
            menuItem.expandActionView();

            new DivvyAsyncTask().execute();

            Bundle bundle = mActivity.getIntent().getExtras();
            List<BikeStation> bikeStations = bundle.getParcelableArrayList("bikeStations");

            if (bikeStations == null) {
                mActivity.startRefreshAnimation();
                mActivity.new LoadData().execute();
            }//from  w  w w .j av  a  2  s  . c om
        }
        Util.trackAction(mActivity, R.string.analytics_category_ui, R.string.analytics_action_press,
                R.string.analytics_action_refresh_bike, 0);
        return false;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.georgeme.Act_Circle.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    boolean handled = false;
    switch (item.getItemId()) {
    case android.R.id.home: // Actionbar home/up icon
        finish();/*  w  w  w . ja  v a  2  s .c om*/
        break;
    case R.id.menu_settings:
        Intent intent = new Intent(this, Act_ShopList.class);
        intent.putExtra("latlng", this.mCenterLatLng);
        startActivity(intent);
        break;
    }
    return handled;
}

From source file:com.almarsoft.GroundhogReader.ComposeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.compose_menu_send:
        postMessage();/*from w  ww  . j a va  2s  . com*/
        return true;
    case R.id.compose_menu_cancel:
        finish();
        return true;
    case R.id.compose_menu_deletetext:
        mEdit_Body.setText("");
        return true;
    case R.id.compose_menu_bigtext:
        setComposeSizeFromPrefs(1);
        return true;
    case R.id.compose_menu_smalltext:
        setComposeSizeFromPrefs(-1);
        return true;
    case R.id.compose_menu_charset:
        startActivity(new Intent(ComposeActivity.this, CharsetActivity.class));
        return true;

    }
    return false;
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }//from ww  w . j a v a2s.  com
    case R.id.poisonings_cards_menu_call: {
        try {
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+4722591300"));
            startActivity(intent);
        } catch (Exception e) {
            new MaterialDialog.Builder(mContext).title(getString(R.string.device_not_supported_dialog_title))
                    .content(getString(R.string.device_not_supported_dialog_message))
                    .positiveText(getString(R.string.device_not_supported_dialog_positive_button))
                    .contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show();
        }

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