Create the dialog in separate class and make a getter for the listener:
public class DatePickerFragment extends DialogFragment
{
private OnDateSetListener onDateSetListener;
public DatePickerFragment() {}
public void setOnDateSetListener(OnDateSetListener onDateSetListener) {
this.onDateSetListener = onDateSetListener;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new DatePickerDialog(getActivity(), onDateSetListener, year, month, day);
}
}
The implementation of DatePickerDialog.OnDateSetListener make in your activity of other fragment where you have reference to your TextView.
Then create a calendar and use SimpleDateFormat, see an example:
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar cal = Calendar.getInstance();
cal.set(year, monthOfYear, dayOfMonth);
<=== YOUR SETTEXT TO YOUR TEXTVIEW HERE ===>
}