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.loadsensing.app.SensorsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.logout:
        SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = settings.edit();
        editor.putString("session", "");
        editor.commit();/*from  www  .  j a v a2s  .co  m*/
        Log.d(DEB_TAG, "SharedPreferences. Session restarted.");
        startActivity(new Intent(getApplicationContext(), LoginActivity.class));
        this.finish();
        return true;
    case R.id.preferences:
        startActivity(new Intent(getApplicationContext(), Preferences.class));
        return true;
    case R.id.exit:
        moveTaskToBack(true);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.mocap.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // When the user clicks FETCH, fetch the first 500 characters of

    case R.id.newlog:

        return true;

    case R.id.bureau:
        try {/*from w ww  .j  a  v a2  s. c o  m*/
            showFragment(this.mbureauFragment);
        } catch (Exception e) {
            Toast.makeText(getBaseContext(), "Erreur show fragment: ", Toast.LENGTH_SHORT).show();

        }

        return true;
    // Clear the log view fragment.
    case R.id.usb_item:
        //   ControlTic controltic=new ControlTic();

        return true;
    case R.id.clear_action:
        //Quitter le programme
        this.finish();
        return true;
    }
    return false;
}

From source file:edu.csh.coursebrowser.SchoolActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        Intent intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);//from  www. j a v a 2 s  . c  o  m
        return true;
    case R.id.menu_about:
        Intent i = new Intent(this, AboutActivity.class);
        startActivity(i);
        return true;
    default:
        return false;
    }
}

From source file:de.elanev.studip.android.app.frontend.forums.ForumEntryComposeFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (isAdded()) {
        switch (item.getItemId()) {
        case android.R.id.home:
            getActivity().onBackPressed();
            return true;
        case R.id.create_new_area:
            createNewEntry();//  ww  w .  j av  a 2s . c  o  m
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }

    return true;
}

From source file:com.springsource.greenhouse.profile.ProfileActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.profile_menu_refresh:
        downloadProfile();//from   ww  w.j  a  v  a2s.  c o  m
        return true;
    case R.id.profile_menu_sign_out:
        signOut();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.drisoftie.cwdroid.frag.FragBoard.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        actionRefresh.invokeSelf();/*from   w  ww  . j  a va  2  s .  co m*/
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.gigathinking.simpleapplock.Upgrade.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        finish();/*from   ww w. jav  a  2 s.c o m*/
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:dentex.youtube.downloader.DonateActivity.java

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

From source file:com.raywenderlich.reposearch.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    return id == R.id.action_settings || super.onOptionsItemSelected(item);

}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_trainer.SignTrainerActiveFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected " + hashCode());
    if (R.id.action_toggle_learning_mode == item.getItemId()) {
        this.onToggleLearningModeListener.toggleLearningMode(LearningMode.PASSIVE);
    }/*from  ww w. ja v a 2  s. c  o m*/
    return super.onOptionsItemSelected(item);
}