teja2495
12/10/2018 - 4:57 AM

Date Picker

DatePickerDialog.OnDateSetListener date;

etDeadline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    new DatePickerDialog(getActivity(), date, myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
});

date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    myCalendar.set(Calendar.YEAR, year);
    myCalendar.set(Calendar.MONTH, monthOfYear);
    myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
    SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy", Locale.US);
    etDeadline.setText(sdf.format(myCalendar.getTime()));
    }
};

/* For Clickable EditText set the following properties in Layout file
android:clickable="true"
android:focusable="false"
android:longClickable="false"
*/