title: How to create a separate time picker class
body: <p>I created the time picker. But in my project, I have required to insert four time picker into the EditText fields.When clicking on the EditText,It will prompt thedailog to set the time.Its so lengthy to create the time picker in the Activity class.So I want to create a separate time picker class. I created the  TimePickerClass, but it shows error.
  Please help me.   </p>
  
  <pre><code>package com.sample.uiscreen;
  
  import android.app.Dialog;
  import android.app.TimePickerDialog;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.TimePicker;
  
  
  public class TimePickClass {
  
  
      private int mHour;
      private int mMinute;
      EditText time;
      public static final int TIME_DIALOG_ID = 0;
      MyActivity ma=null;
  
  
  
  
  // the callback received when the user "sets" the time in the dialog
     public  TimePickerDialog.OnTimeSetListener mTimeSetListener =    
                      new TimePickerDialog.OnTimeSetListener() {
         public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
             mHour = hourOfDay;
             mMinute = minute;
             time.setText(        
                      new StringBuilder()
                      .append(pad(mHour)).append(":")
                      .append(pad(mMinute)));}
       //pad method
         private String pad(int c) {
             if (c &gt;= 10)
                 return String.valueOf(c);
             else        return "0" + String.valueOf(c);       }    };
  
             protected Dialog onCreateDialog(int id) {
                 switch (id) {    
                 case TIME_DIALOG_ID:        
              return new TimePickerDialog(ma,
                      mTimeSetListener, mHour, mMinute, true);    }    
                 return null; }
  
  
  
  
  
  }
  </code></pre>