Java Code Examples for android.view.MenuItem.getItemId()

The following are Jave code examples for showing how to use getItemId() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Expert-Android-Programming   File: BeenThereActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case android.R.id.home:
            onBackPressed();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 2
Project: Ae4Team   File: PurchaseHistoryActivity.java   View Source Code Vote up 5 votes
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            IntentBack();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 3
Project: SmackStudy   File: MainActivity.java   View Source Code Vote up 5 votes
@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();

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

    return super.onOptionsItemSelected(item);
}
 
Example 4
Project: Cable-Android   File: StickerSelectActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  if (item.getItemId() == android.R.id.home) {
    onBackPressed();
    return true;
  }
  return super.onOptionsItemSelected(item);
}
 
Example 5
Project: barbapapa   File: AdvancedRecommandationActivity.java   View Source Code Vote up 5 votes
@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();

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

    return super.onOptionsItemSelected(item);
}
 
Example 6
Project: moneytracking   File: MainActivity.java   View Source Code Vote up 5 votes
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.nav_home) {
        Intent intent = new Intent(MainActivity.this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

    } else if (id == R.id.nav_planned) {
        startActivity(new Intent(MainActivity.this, PlannedActivity.class));

    } else if (id == R.id.nav_category) {
        startActivity(new Intent(MainActivity.this, CategoriesActivity.class));

    } else if (id == R.id.nav_graph) {
        startActivity(new Intent(MainActivity.this, ChartTypeActivity.class));

    } else if (id == R.id.nav_archive) {
        startActivity(new Intent(MainActivity.this, ArchiveActivity.class));

    } else if (id == R.id.nav_report) {
        startActivity(new Intent(MainActivity.this, ReportActivity.class));

    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return false;
}
 
Example 7
Project: quickblox-android   File: ScreenShareFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.stop_screen_share:
            Log.d(TAG, "stop_screen_share");
            if (onSharingEvents != null) {
                onSharingEvents.onStopPreview();
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 8
Project: Instincts-2k17   File: DayViewActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 9
Project: schulcloud-mobile-android   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.main_action_settings:
            startActivity(new Intent(this, SettingsActivity.class));
            return true;

        case R.id.main_action_logout:
            goToSignIn();
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 10
Project: MyCalendar   File: WeekLessonDetailActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case android.R.id.home:
            onBackPressed();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 11
Project: Camera-warner   File: SettingsActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    // When the home button is pressed, take the user back to the VisualizerActivity
    if (id == android.R.id.home) {
        NavUtils.navigateUpFromSameTask(this);
    }
    return super.onOptionsItemSelected(item);
}
 
Example 12
Project: AndroidRTC   File: ConnectActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == REMOVE_FAVORITE_INDEX) {
        AdapterView.AdapterContextMenuInfo info =
                (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        roomList.remove(info.position);
        adapter.notifyDataSetChanged();
        return true;
    }

    return super.onContextItemSelected(item);
}
 
Example 13
Project: dankbank   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_settings:
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 14
Project: Phoenix-for-VK   File: CreatePollFragment.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case (R.id.add_menu):
            getPresenter().fireDoneClick();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 15
Project: Canvas-Vision   File: NavActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home)
    {
        finish();
    }

    return super.onOptionsItemSelected(item);
}
 
Example 16
Project: DoorPhone   File: SettingsActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == android.R.id.home) {
        startActivity(new Intent(getActivity(), SettingsActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 17
Project: mobile-app-dev-book   File: MediaDetailsActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.save_media) {
        switch (mediaType) {
            case 1: // text
                DateTime now = DateTime.now();
                DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
                JournalEntry currentEntry = new JournalEntry();
                currentEntry.setCaption(entry_caption.getText().toString());
                currentEntry.setType(mediaType);
                currentEntry.setLat(ALLENDALE_LAT);
                currentEntry.setLng(ALLENDATE_LNG);
                currentEntry.setDate(fmt.print(now));

                DatabaseReference savedEntry = entriesRef.push();
                savedEntry.setValue(currentEntry);
                Snackbar.make(entry_caption,
                        "Your entry is saved",
                        Snackbar.LENGTH_LONG).show();
                break;
            case 2: // photo
                uploadMedia(mediaType, "image/jpeg", "photos");
                break;
            case 3: // audio
                uploadMedia(mediaType, "audio/m4a", "audio");

                break;
            case 4: // video
                uploadMedia(mediaType, "video/mp4", "videos");
                break;
        }
        return true;
    }
    return false;
}
 
Example 18
Project: PingWidget   File: HomeActivity.java   View Source Code Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        // Respond to the mToolbar's back/home button
        case android.R.id.home:
            onBackPressed();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 19
Project: Espresso   File: PackageDetailsFragment.java   View Source Code Vote up 4 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {

        exit();

    } else if (id == R.id.action_delete) {

        showDeleteAlertDialog();

    } else if (id == R.id.action_set_readable) {

        presenter.setPackageUnread();

    } else if (id == R.id.action_copy_code) {

        presenter.copyPackageNumber();

    } else if (id == R.id.action_share) {

        presenter.shareTo();

    }
    return true;
}
 
Example 20
Project: Celebino   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    builder = new AlertDialog.Builder(this);
    if (item.getItemId() == R.id.action_add) {
        switch (fragment) {
            case 1: // HomeFragment
                view = getLayoutInflater().inflate(R.layout.dialog_choice, null);
                Button btAir = (Button) view.findViewById(R.id.btAir);
                Button btGarden = (Button) view.findViewById(R.id.btGarden);

                btAir.setOnClickListener(new ChoiceOnClickListener(this, true));
                btGarden.setOnClickListener(new ChoiceOnClickListener(this, false));
                showDialog();
                break;
            case 2: // AirFragment
                setViewInsert();
                btSave.setOnClickListener(new AirBtSaveOnClickListener(this));

                showDialog();
                break;
            case 3: // GardenFragment
                setViewInsert();
                btSave.setOnClickListener(new GardenBtSaveOnClickListener(this));

                showDialog();

                break;
            case 4: // no itens Air
                setViewInsert();
                btSave.setOnClickListener(new AirBtSaveOnClickListener(this));

                showDialog();
                break;
            case 5: // no itens garden
                setViewInsert();
                btSave.setOnClickListener(new GardenBtSaveOnClickListener(this));

                showDialog();
                break;
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}