コード例 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Switch to login activity
      case R.id.button_add:
        // Check if user currently logged in
        currentUser = ParseUser.getCurrentUser();
        if (currentUser == null) {
          Toast.makeText(getApplicationContext(), "Please log in to add items.", Toast.LENGTH_SHORT)
              .show();
          Intent intentLoginAdd = new Intent(getApplicationContext(), LoginActivity.class);
          intentLoginAdd.putExtra("resName", resName);
          startActivity(intentLoginAdd);
          return false;
        }

        // Show dialog box for adding user data
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        final AddDialogFragment dfrag = AddDialogFragment.newInstance(resName);
        // final AddDialogFragment dfrag = new AddDialogFragment();
        dfrag.show(ft, "add");
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #2
0
ファイル: addActivity.java プロジェクト: Shark919/appXpired
 private void showPopup() {
   AddDialogFragment popup = new AddDialogFragment();
   FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
   DialogFragment newFragment = AddDialogFragment.newInstance(1);
   newFragment.show(ft, "dialog");
 }