Ejemplo n.º 1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      Util.showToast(this, "你选择了设置");
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
Ejemplo n.º 2
0
  /**
   * 左侧导航根据位置进行相应的操作
   *
   * @param number
   */
  public void onSectionAttached(int number) {
    Class TargetActivity = null;
    switch (number) {
      case 0: // 修改头像
        Intent toChangeInfo = new Intent(this, ChangeInfoActivity.class);
        toChangeInfo.putExtra(Util.SHIFT_FLAG, getString(R.string.change_icon));
        startActivity(toChangeInfo);
        break;
      case 1: // 修改昵称
        toChangeInfo = new Intent(this, ChangeInfoActivity.class);
        toChangeInfo.putExtra(Util.SHIFT_FLAG, getString(R.string.change_name));
        startActivity(toChangeInfo);
        break;
      case 2:
        mTitle = getString(R.string.title_section1);
        Util.showToast(this, "你点击了第一项");
        break;
      case 3:
        mTitle = getString(R.string.title_section2);
        TargetActivity = PdfParseActivity.class;
        Intent to = new Intent(this, TargetActivity);
        startActivity(to);
        break;
      case 4:
        mTitle = getString(R.string.title_section3);
        Util.showToast(this, "你点击了第三项");

        break;
      case 5:
        mTitle = getString(R.string.title_section4);
        Util.showToast(this, "反馈建议");
        break;
      default:
        break;
    }
  }
Ejemplo n.º 3
0
 @Override
 public void onBackPressed() {
   Fragment curFragment = mFragManager.findFragmentById(R.id.fragment_container);
   if (curFragment instanceof WordClassifyFragment
       || curFragment instanceof MessageClassifyFragment
       || curFragment instanceof ArticleListFragment
       || curFragment instanceof EnglishClassify) {
     long endTime = System.currentTimeMillis();
     if (endTime - startTime < 2000) {
       finish();
     } else {
       startTime = System.currentTimeMillis();
       Util.showToast(this, R.string.press_back_again);
     }
   } else {
     mFragManager.popBackStack();
   }
 }