コード例 #1
0
  // code which handles the action for each menu item
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.settings:
        {
          Intent preferences_intent = new Intent();
          preferences_intent.setComponent(
              new ComponentName(download_photos.this, preferences.class));
          preferences_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplicationContext().startActivity(preferences_intent);

          return true;
        }
      case R.id.logout:
        {
          try {
            download_photos.this.facebook.logout(getApplicationContext());
          } catch (IOException e) {
            e.printStackTrace();
          }

          mPrefs = getSharedPreferences("COMMON", MODE_PRIVATE);

          SharedPreferences.Editor editor = mPrefs.edit();
          editor.putString("access_token", null);
          editor.putLong("access_expires", 0);
          editor.putBoolean("logout", true);
          editor.commit();
          finish();
          return true;
        }
      case R.id.about:
        {
          // shows our customized about dialog
          AboutDialog about = new AboutDialog(this);

          about.show();
          return true;
        }
        // lets deal with default case
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #2
0
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.LogoutMenuItem:
       VApplication.logout(this);
       return true;
     case R.id.AboutMenuItem:
       AboutDialog.makeDialog(this).show();
       return true;
     case R.id.ExitMenuItem:
       // VApplication.stopService(this);
       VApplication.exit();
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
コード例 #3
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    setProgressBarIndeterminateVisibility(true);

    HomeGridAdapter.Item item =
        (HomeGridAdapter.Item) HomeGridActivity.this.adapter.getItem(position);
    Intent intent = item.getIntent();

    changeTitle(item.getTitle());

    if (item.getType() == HomeGridAdapter.ItemType.HELP) {
      AboutDialog.makeDialog(this).show();
      backToHome();
    } else if (intent != null) {
      startActivity(intent);
    } else {
      Toast.makeText(this, "Not implemented", Toast.LENGTH_SHORT).show();
      backToHome();
    }
  }