I have this code here on the options menu
Dialog dialog = new Dialog(ScheduleActivity.this);
dialog.setTitle(\"Add Event\");
dialog.setContentView(R.layout.
This is my helper function which get context and TextView as parameter and sets Date on that text view when user select a date:
public static void showDate(final Context context, final TextView textView) {
if (textView != null) {
final Calendar myCalendar = Calendar.getInstance();
DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
String myFormat = "MM/dd/yy"; // In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
//UIHelper.showLongToastInCenter(context, sdf.format(myCalendar.getTime()));
textView.setText(sdf.format(myCalendar.getTime()));
}
};
new DatePickerDialog(context, date, myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
} else {
UIHelper.showLongToastInCenter(context, "Unable to show Date picker");
}
}