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.amanmehara.programming.android.activities.ProgramActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
    case R.id.action_rate: {
        rate();// w  w  w  .  ja v  a2s.  c  o  m
        return true;
    }
    case android.R.id.home: {
        Map<String, Serializable> extrasMap = new HashMap<>();
        extrasMap.put("accessToken", accessToken);
        startActivity(LanguageActivity.class, extrasMap);
        return true;
    }
    default: {
        return super.onOptionsItemSelected(item);
    }
    }
}

From source file:com.springsource.greenhouse.events.EventsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.events_menu_refresh:
        downloadEvents();/*from www . j  a  va2 s.  com*/
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.amanmehara.programming.android.activities.LanguageActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
    case R.id.action_rate: {
        rate();/*ww w . ja v  a2  s  .com*/
        return true;
    }
    case android.R.id.home: {
        startActivity(MainActivity.class);
        return true;
    }
    default: {
        return super.onOptionsItemSelected(item);
    }
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected() " + this.hashCode());
    switch (item.getItemId()) {
    case android.R.id.home:
        final Intent upIntent = NavUtils.getParentActivityIntent(this);
        upIntent.putExtra(SearchManager.QUERY, this.originalQuery);
        NavUtils.navigateUpTo(this, upIntent);
        return true;
    }//w ww  .j a  v  a2s  .c  o m
    return super.onOptionsItemSelected(item);
}

From source file:com.perm.DoomPlay.AbstractVkItems.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.itemRefresh:
        if (isLoading)
            AbstractList.waitMessage(getBaseContext());
        if (!MainScreenActivity.isRegister)
            Toast.makeText(getBaseContext(), getResources().getString(R.string.please_sign_in),
                    Toast.LENGTH_SHORT).show();
        else/*from   w  ww . j  a v a2s.co  m*/
            onClickRefresh();
        return true;
    case R.id.itemInterrupt:
        cancelLoading();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:edu.asu.bscs.csiebler.waypointdatabase.MainActivity.java

/**
 * 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.
 *
 * @param item// www. j  av  a  2s.co  m
 * @return
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.loopj.android.http.sample.Redirect302Sample.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.isCheckable()) {
        item.setChecked(!item.isChecked());
        if (item.getItemId() == 0) {
            enableRedirects = item.isChecked();
        } else if (item.getItemId() == 1) {
            enableRelativeRedirects = item.isChecked();
        } else if (item.getItemId() == 2) {
            enableCircularRedirects = item.isChecked();
        }/*from w  ww .  j  a v a  2 s . com*/
    }
    return super.onOptionsItemSelected(item);
}

From source file:hr.kodbiro.quickbyte.activities.TrolleyActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.confirm_order:
        Map<String, Integer> confirmMap;

        List<Map<String, Integer>> confirmList = new ArrayList<Map<String, Integer>>();

        // get each item's ID, parse to Json and send request (order)
        for (Order order : orderList) {
            for (int i = 0; i < order.getOrderQuantity(); i++) {
                confirmMap = new HashMap<String, Integer>();
                confirmMap.put("id", order.getOrderID());
                confirmList.add(confirmMap);
            }//from  w  w w .  j a  v  a2 s  . com
        }
        Gson gson = new Gson();
        sendOrder(gson.toJson(confirmList));
        break;
    case R.id.clear_trolley:
        orderList.clear();
        finishActivityWithList();
    default:
        break;
    }
    return true;
}

From source file:com.dev.pygmy.game.GameListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    default://  w  ww  .  ja  v  a 2s  .  c om
        break;
    }
    return false;
}

From source file:it.scoppelletti.mobilepower.app.CommonMenuFragment.java

/**
 * Gestione della selezione di una voce di men&ugrave;.
 * //from w ww. j a  v a  2  s.  c  o m
 * @param  item Voce di men&ugrave;
 * @return      Indicatore di evento gestito.
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    String action = null;
    Intent intent = null;
    Context ctx = getActivity();

    if (itemId == R.id.cmd_settings) {
        action = CommonMenuFragment.ACTION_SETTINGS;
    } else if (itemId == R.id.cmd_help) {
        action = CommonMenuFragment.ACTION_HELP;
    } else if (itemId == R.id.cmd_about) {
        action = CommonMenuFragment.ACTION_ABOUT;
    } else if (itemId == R.id.cmd_buy) {
        intent = AppUtils.newBuyIntent(ctx);
    }
    if (action != null) {
        intent = new Intent(action);
        intent.setPackage(ctx.getPackageName());
    }
    if (intent != null) {
        ctx.startActivity(intent);
        return true;
    }

    return super.onOptionsItemSelected(item);
}