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.QuarkLabs.BTCeClient.fragments.OrdersBookFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        Bundle bundle = new Bundle();
        bundle.putString("pair", mPairsSpinner.getSelectedItem().toString());
        getLoaderManager().restartLoader(LOADER_ID, bundle, this);
        break;//from  w  ww  .  j a v a  2s.c o m
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Respond to the action bar's Up/Home button
    // navigate up to parent activity (MainActivity)
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }//  w  w w . j a  v a  2  s . c o m
    return super.onOptionsItemSelected(item);
}

From source file:com.cloudkick.DashboardActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.refresh_dashboard:
        refreshNodes();//from  ww w  .j a v a 2s. c om
        return true;
    case R.id.log_out:
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("editKey", "");
        editor.putString("editSecret", "");
        editor.commit();
        nodes.clear();
        adapter.notifyDataSetChanged();
        Intent loginActivity = new Intent(getBaseContext(), LoginActivity.class);
        startActivityForResult(loginActivity, LOGIN_ACTIVITY_ID);
        return true;
    case R.id.settings:
        Intent settingsActivity = new Intent(getBaseContext(), Preferences.class);
        startActivityForResult(settingsActivity, SETTINGS_ACTIVITY_ID);
        return true;
    default:
        // If its not recognized, do nothing
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.mercandalli.android.apps.files.user.ConversationActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from  w  w  w.  ja  v a  2s  . c o m
        overridePendingTransition(R.anim.right_in, R.anim.right_out);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.miuidev.themebrowser.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.MenuThemeManager:
        final Intent intentThemeManager = new Intent("android.intent.action.MAIN");
        intentThemeManager.setComponent(new ComponentName("com.android.thememanager",
                "com.android.thememanager.ThemeSettingsActivity"));
        try {//from  ww  w  . j  av  a 2 s .  c  om
            startActivity(intentThemeManager);
        } catch (ActivityNotFoundException e) {
            Context context = getApplicationContext();
            CharSequence text = getString(R.string.theme_manager_not_found);
            int duration = Toast.LENGTH_SHORT;

            Toast toast = Toast.makeText(context, text, duration);
            toast.show();
        }
        return true;
    case R.id.MenuAbout:
        displayAbout();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:au.id.tedp.mapdroid.Picker.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.my_location:
        Location loc = getLastLocation((Context) this);
        if (loc == null) {
            Log.d("Mapdroid", "Location is null");
        } else {//from w  w  w  . java  2 s . c o  m
            Log.d("Mapdroid", "Location is not null");
        }
        // FIXME: Notify user if there is no location source
        // or turn GPS on for them
        if (loc != null) {
            OSMMapView map = (OSMMapView) findViewById(R.id.mapView);
            Log.d("MapView", map.toString());
            map.setCenterCoords((float) loc.getLatitude(), (float) loc.getLongitude());
            map.setZoom(15);
        }
        return true;
    }
    return false;
}

From source file:com.sakisds.icymonitor.fragments.ProcessesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.item_sort_by_name:
        mSort = "name";
        mPullToRefreshLayout.setRefreshing(true);
        refreshData();/*from ww w.j  a v  a 2 s  . c  o m*/
        item.setChecked(true);
        return true;
    case R.id.item_sort_by_usage:
        mSort = "usage";
        mPullToRefreshLayout.setRefreshing(true);
        refreshData();
        item.setChecked(true);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.example.office.ui.calendar.EventFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.event_options, menu);

    // This will be called as soon as user presses the attach menu item to attach image to current event
    menu.findItem(R.id.action_attach).setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_attach:
                mImagePicker.showAttachImageDialog();
                return true;

            default:
                return false;
            }/*  w ww .  ja v a2s  .  c o  m*/
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:MainActivity.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 == R.id.action_settings) {
        return true;
    }/*from  w w w.j a v  a2s  .com*/

    return super.onOptionsItemSelected(item);
}

From source file:fr.cph.stock.android.activity.OverallActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    MainTask mainTask;//from  www.  j  a  va2 s.  c o m
    switch (item.getItemId()) {
    case R.id.action_logout:
        mainTask = new MainTask(this, UrlType.LOGOUT, null);
        mainTask.execute((Void) null);
        return true;
    case R.id.refresh:
        menuItem = item;
        menuItem.setActionView(R.layout.progressbar);
        menuItem.expandActionView();
        tracker.sendEvent("Buttons Category", "Reload", "", 0L);
        mainTask = new MainTask(this, UrlType.RELOAD, null);
        mainTask.execute((Void) null);
        return true;
    case R.id.action_update:
        showPanelUpdateHistory();
        return true;
    case android.R.id.home:
        finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}