コード例 #1
0
  /**
   * Response to add crime action button.
   *
   * <p>Toggling the action item subtitle.
   *
   * @param item
   * @return
   */
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.menu_item_new_crime:
        Crime crime = new Crime();
        CrimeLab.getInstance(getActivity()).addCrime(crime);
        Intent intent = CrimePagerActivity.newIntent(getActivity(), crime.getId());
        startActivity(intent);
        return true;

      case R.id.menu_item_show_subtitle:
        mSubtitleVisible = !mSubtitleVisible;
        getActivity().invalidateOptionsMenu();
        updateSubtitle();
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #2
0
 @Override
 public void onClick(View v) {
   Intent intent = CrimePagerActivity.newIntent(getActivity(), mCrime.getId());
   startActivity(intent);
 }
コード例 #3
0
 /**
  * Helper method to update View with the Model
  *
  * @param crime
  */
 public void bindCrime(Crime crime) {
   mCrime = crime;
   mTextViewTitle.setText(mCrime.getTitle());
   mTextViewDate.setText(mCrime.getFormattedDate());
   mCheckBoxSolved.setChecked(mCrime.isSolved());
 }