title: How to put a timer in an android dialog
body: <p>how can I put a Timer in an android dialog? I have all the dialog methods built, but I can't seem to figure out how to update the text in the dialog view every time the timer fires. my update method is already getting called once per second by another class. </p>
  
  <p>here's my code so far:</p>
  
  <pre><code>    public class PlaybackTimerEndingDialog extends DialogFragment implements TimerCallbacks.updateTimer {
      private AlertDialog.Builder mBuilder;
      private long mTime;
      private Context mContext;
      private View mTimerEndingView;
  
      public PlaybackTimerEndingDialog(long startTime, Context context){
          this.mTime = startTime;
          this.mContext = context;
      }
  
  
      private void updateView(String message_text){
          LayoutInflater inflater = this.getActivity().getLayoutInflater();
          this.mTimerEndingView = inflater.inflate(R.layout.playback_timer_ending, null);
          TextView messageView = (TextView) this.mTimerEndingView.findViewById(R.id.timer_ending_message);
          messageView.setText(message_text);
      }
  
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // Use the Builder class for convenient dialog construction
          this.updateView("The sleep timer will expie in "+ this.formatTime(this.mTime));
  
          this.mBuilder = new AlertDialog.Builder(this.mContext)
          //      this.mBuilder.setMessage("The sleep timer will expie in "+ this.formatTime(this.mTime))
          .setPositiveButton("Add more time", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                  TimerCallbacks.createTimer listener = (TimerCallbacks.createTimer) PlaybackTimerEndingDialog.this.mContext;
                  listener.createTimerDialog();
              }
          })
          .setNegativeButton("Cancel timer", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                  TimerCallbacks.createTimer listener = (TimerCallbacks.createTimer) PlaybackTimerEndingDialog.this.mContext;
                  listener.stopTimer();
              }
          });
          this.mBuilder.setView(this.mTimerEndingView);
          // Create the AlertDialog object and return it
          return this.mBuilder.create();
      }
  
      @Override
      public void finished() {
          // TODO Auto-generated method stub
      }
  
      @Override
      public void update(long time) {
          // TODO Auto-generated method stub
          //      this.getDialog().set
          this.updateView("The sleep timer will expie in "+ this.formatTime(time));
          this.mTime = time;
          Log.d("current time", Long.toString(time));
          //      this.mBuilder.setMessage("The sleep timer will expie in "+ this.formatTime(time));
      }
  
      private String formatTime(long time) {
          int seconds = (int) (time / 1000) % 60 ;
          int minutes = (int) ((time / (1000*60)) % 60);
          String mnStr = (minutes&lt;10 ? "0" : "")+minutes;
          String secStr = (seconds&lt;10 ? "0" : "")+seconds;
          return "-"+mnStr +":"+ secStr;
      }
  }
  </code></pre>
  
  <p>any help with this would be greatly appreciated. </p>