0

In my application i have used date time picker.When i click cancel button on date picker time picker dialog is displaying which i don't want. When i click cancel button the date picker should dismiss it shouldn't go to time picker dialog.Can anyone help me with this? When i execute on emulator only set button is displaying but while executing on device both set button and cancel button is displaying i couldn't find where the issue is.

@SuppressLint("ValidFragment")
public class DatePickerFragment extends DialogFragment implements
        DatePickerDialog.OnDateSetListener {

    public EditText activity_edittext;

    public DatePickerFragment(EditText edit_text) {
        activity_edittext = edit_text;
    }

    @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);

        return new DatePickerDialog(getActivity(), this, year, month, day);
    }

    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear,
            int dayOfMonth) {
Log.d("date",String.valueOf(day) + "/"
                + String.valueOf(month + 1) + "/" + String.valueOf(year));
        activity_edittext.setText(String.valueOf(day) + "/"
                + String.valueOf(month + 1) + "/" + String.valueOf(year));
    }
Praveen Sharma
  • 4,322
  • 5
  • 23
  • 44
june
  • 959
  • 3
  • 12
  • 19

0 Answers0