title: Using Different types of Dialogs in Same Activity
body: <p>First off, I'm brand new to android development, and mostly brand new to programming, so please bear with me. I've got one Activity with several buttons. The first button, 'Name of Workout', opens up a custom AlertDialog that let's me input some text, and then puts that text in a textview to the right of the button. </p>
  
  <p>What I want the second button to do, 'Date of Workout', is to open a date picker dialog right here in the same activity, in the same manner that the first button works. I finally pieced together the correct code to get this to work, but in a different activity. So really I need to figure out is how to modify this code:</p>
  
  <pre><code>package com.example.test_project;
  
  import java.util.Calendar;
  
  import android.app.Activity;
  import android.app.DatePickerDialog;
  import android.app.Dialog;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.DatePicker;
  import android.widget.TextView;
  
  public class TimePickerFragment extends Activity {
  /** Called when the activity is first created. */
  
     private TextView mDateDisplay;
      private Button mPickDate;
      private int mYear;
      private int mMonth;
      private int mDay;
  
      static final int DATE_DIALOG_ID = 0;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_new_workout);
  
      // capture our View elements
      mDateDisplay = (TextView) findViewById(R.id.timeOfWorkoutTextView);
      mPickDate = (Button) findViewById(R.id.dateOfWorkoutButton);
  
      // add a click listener to the button
      mPickDate.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              showDialog(DATE_DIALOG_ID);
          }
      });
  
      // get the current date
      final Calendar c = Calendar.getInstance();
      mYear = c.get(Calendar.YEAR);
      mMonth = c.get(Calendar.MONTH);
      mDay = c.get(Calendar.DAY_OF_MONTH);
  
      // display the current date (this method is below)
      updateDisplay();
  }
  
  // updates the date in the TextView
  private void updateDisplay() {
          StringBuilder string1 = new StringBuilder()
                  // Month is 0 based so add 1
                  .append(mMonth + 1).append("-")
                  .append(mDay).append("-")
                  .append(mYear).append(" ");
      mDateDisplay.setText(string1);
  }
  
  // the callback received when the user "sets" the date in the dialog
  private DatePickerDialog.OnDateSetListener mDateSetListener =
          new DatePickerDialog.OnDateSetListener() {
  
              public void onDateSet(DatePicker view, int year,
                                    int monthOfYear, int dayOfMonth) {
                  mYear = year;
                  mMonth = monthOfYear;
                  mDay = dayOfMonth;
                  updateDisplay();
              }
          };
  
  @Override
  protected Dialog onCreateDialog(int id) {
      switch (id) {
      case DATE_DIALOG_ID:
          return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
                  mDay);
      }
      return null;
  }
  }
  </code></pre>
  
  <p>To work within the timeOfWorkout method of this code:</p>
  
  <pre><code>package com.example.test_project;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  
  public class NewWorkout extends Activity  {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_new_workout);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.new_workout, menu);
      return true;
  }
  
  TextView mDateDisplay;
  Button mPickDate;
  int mYear;
  int mMonth;
  int mDay;
  
  final int DATE_DIALOG_ID = 0;
  
  
  
  
  public void timeOfWorkout(View view){
  
      }
  
  
  
  
  
  public void nameOfWorkout(View view){
      AlertDialog.Builder alert = new AlertDialog.Builder(this);
  
      alert.setTitle("Enter a Name for This Workout");
  
      // Set an EditText view to get user input 
      final EditText input = new EditText(this);
      alert.setView(input);
  
      alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int whichButton) {
        String value = input.getText().toString();
        TextView edit = (TextView) findViewById(R.id.nameOfWorkoutTextView);
        edit.setText(value);
        // Do something with value!
        }
      });
  
      alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          // Canceled.
        }
      });
  
      alert.show();
  
  }
  
  }
  </code></pre>
  
  <p>I've tried to modify it for hours now, and have always ran into one problem or another... I'm pretty sure I don't have enough of a fundamental grasp of Java or Android Development or how different activities and files work together to make this work yet, so any help would be greatly Appreciated!!!</p>