Domanda

I have an issue trying to create a dialog on event on click of a button but there is no dialog from where i can choose the date here is my code

I am calling on buttonCLick showDialog(2);

protected Dialog onCreateDialog(int id)
{
    switch (id)
    {
        case 2:return showDatePicker();
    }

    return dialog;
}

private DatePickerDialog showDatePicker()
{
    DatePickerDialog datePicker= new DatePickerDialog(dodadi.this, new DatePickerDialog.OnDateSetListener() {
        //@Override
        public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth)
        {   
            mCalendar.set(Calendar.YEAR,year);
            mCalendar.set(Calendar.MONTH,monthOfYear);
            mCalendar.set(Calendar.DAY_OF_MONTH,dayOfMonth);
            updateDateButtonText();
            //super.onDateSet(view,year,monthOfYear,dayOfMonth);
        }
    }, mCalendar.get(Calendar.YEAR),mCalendar.get(Calendar.MONTH),mCalendar.get(Calendar.DAY_OF_MONTH));

    return datePicker;
}
È stato utile?

Soluzione

Probably it's the import because the code is correct try import android.app.DatePickerDialog; it can be widget instead of app :) stupid error

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top