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.rvl.android.getnzb.GetNZB.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_PREFS:
        startPreferences();//from w ww . ja v  a  2  s .  co  m
        return true;
    case MENU_QUIT:
        quit();
        return true;
    case MENU_ABOUT:
        showDialog(DIALOG_ABOUT);
        return true;
    }
    return false;
}

From source file:net.alchemiestick.katana.winehqappdb.SearchView.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.about:
        showDialog(ABOUT_DLG);/*from ww w.  j  ava2 s  .c o m*/
        return true;
    case R.id.filters:
        // still to be done. based on setDefaults();
        showDialog(FILTERS_DLG);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.skalski.raspberrycontrol.Activity_RemoteControl.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 w w  .ja v a  2s. co 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.setHandler(clientHandler);
                Log.i(LOGTAG, LOGPREFIX + "reconnecting to server");
            }
        }
        break;
    }
    return true;
}

From source file:com.nttec.everychan.ui.FavoritesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_clear_favorites) {
        if (pagerAdapter != null) {
            MainApplication.getInstance().database.clearFavorites();
            update();/*from  w  w  w . java 2 s.c  om*/
        }
        return true;
    }
    return false;
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.itemRefresh:
        if (isLoading)
            AbstractList.waitMessage(getBaseContext());
        else if (!MainScreenActivity.isRegister)
            Toast.makeText(getBaseContext(), getResources().getString(R.string.please_sign_in),
                    Toast.LENGTH_SHORT).show();
        else if (!Utils.isOnline(getBaseContext()))
            Toast.makeText(getBaseContext(), getResources().getString(R.string.check_internet),
                    Toast.LENGTH_SHORT).show();
        else {//from  ww w  .  ja v  a 2  s .  c o m
            refreshAudios();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java

private void findViews() {
    Toolbar mToolbar = (Toolbar) v.findViewById(R.id.toolbar_weight);
    TextViewFont txtTitle = (TextViewFont) v.findViewById(R.id.txtTitle);
    txtTitle.setText("Weight");
    mToolbar.inflateMenu(R.menu.menu_weight);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override/*from  w  ww  .  jav a  2s . c  om*/
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.action_create) {
                FragmentManager fm = getActivity().getSupportFragmentManager();
                UpdateWeightDialogFragment suggestionFragment = new UpdateWeightDialogFragment();
                suggestionFragment.show(fm, "Fragment");
            }
            return false;
        }
    });
    mToolbar.setNavigationIcon(R.mipmap.ic_menu);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallbacks.openNavigationDrawer();
        }
    });
    weightLogAdapter = new WeightLogAdapter(getActivity(), 0, WeightLog.all());
    listWeight = (ListView) v.findViewById(R.id.listWeight);
    listWeight.setAdapter(weightLogAdapter);
    SetWeightListHeight.setListViewHeight(listWeight);
    WeightLog weightLogStart = weightLogAdapter.getItem(0);
    TextView startWeight = (TextView) v.findViewById(R.id.startWeight);
    startWeight.setText(df.format(weightLogStart.getCurrentWeight()) + " lbs");
    WeightLog weightLogCurrent = weightLogAdapter.getItem(weightLogAdapter.getCount() - 1);
    TextView currentWeight = (TextView) v.findViewById(R.id.currentWeight);
    currentWeight.setText(df.format(weightLogCurrent.getCurrentWeight()) + " lbs");
    double totalWeightLoss = weightLogStart.getCurrentWeight() - weightLogCurrent.getCurrentWeight();
    TextView lossWeight = (TextView) v.findViewById(R.id.lossWeight);
    lossWeight.setText(df.format(totalWeightLoss) + " lbs");
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    TextView goalWeight = (TextView) v.findViewById(R.id.goalWeight);
    goalWeight.setText(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "") + " lbs");
    double weightRemaining = weightLogCurrent.getCurrentWeight()
            - Double.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, ""));
    TextView remainderWeight = (TextView) v.findViewById(R.id.remainderWeight);
    remainderWeight.setText(df.format(weightRemaining) + " lbs");
    max = (int) Precision.round(weightLogStart.getCurrentWeight(), -1) + 10;
    if (Double.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "")) < weightLogCurrent
            .getCurrentWeight()) {
        min = (int) Precision.round(Integer.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, "")),
                -1) - 10;
    } else {
        min = (int) Precision.round(weightLogCurrent.getCurrentWeight(), -1) - 10;
    }
    goalWeightLine = Float.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_GOAL, ""));

    goalPosition = Integer.valueOf(sharedPreferences.getString(Globals.USER_WEIGHT_LOSS_GOAL, ""));
    if (goalPosition == 0 || goalPosition == 8) {
        weightPerWeek = 2;
    }
    if (goalPosition == 1 || goalPosition == 7) {
        weightPerWeek = 1.5;
    }
    if (goalPosition == 2 || goalPosition == 6) {
        weightPerWeek = 1;
    }
    if (goalPosition == 3 || goalPosition == 5) {
        weightPerWeek = .5;
    }
    if (goalPosition == 4) {
        weightPerWeek = 0;
    }
    timeTillGoal = weightRemaining / weightPerWeek;

    TextView timeRem = (TextView) v.findViewById(R.id.timeRem);
    timeRem.setText(df.format(timeTillGoal) + " Week(s)");
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected " + hashCode());
    if (item.getItemId() == R.id.action_toggle_starred) {
        if (!this.showStarredOnly) {
            this.showStarredOnly = true;
            item.setIcon(R.drawable.ic_sign_browser_grade_checked);
        } else {// w  ww  .  ja  v a 2  s.c o m
            this.showStarredOnly = false;
            item.setIcon(R.drawable.ic_sign_browser_grade_no_stroke);
        }
        this.loadSignsTask = new LoadSignsTask(getActivity());
        this.loadSignsTask.execute(this.showStarredOnly);
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.fabernovel.alertevoirie.HomeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_CREDITS:
        Intent i = new Intent(this, CreditsActivity.class);
        startActivity(i);/*from ww  w.jav a 2s .  co m*/
        break;

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

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.set_settings:
        startActivity(new Intent(this, SettingsActivity.class));
        return true;
    case R.id.set_report:
        onReportClick();/*ww  w  .j a va 2s.co  m*/
        return true;
    case android.R.id.home:
        setResult(RESULT_CANCELED);
        finish();
        return true;
    default:
        break;
    }
    return false;
}

From source file:com.gimranov.zandy.app.LookupActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.do_prefs:
        startActivity(new Intent(this, SettingsActivity.class));
        return true;
    default:// w w w  .  j  a v  a  2s  .co  m
        return super.onOptionsItemSelected(item);
    }
}