I am working on datepicker
dialog and one issue that i am facing is to have the cancel button on the picker(no cancel button for android jelly bean). now the problem is also with that my datepicker dialog is getting invoked on button(in listview
adapter class) press.In adapter class i am using date_picker_id concept.. Any help would be really appreciated.
((Activity) LessonListViewAdapter.this.context).showDialog(DATE_DIALOG_ID);
This calls the createdialog function in Activity
.
Jelly Bean DatePickerDialog --- is there a way to cancel? answer in the link gives you way to work around. I found this link trying to answer the one of the question regarding data picker.
Looks like it's a bug and someone else already filled it.http://code.google.com/p/android/issues/detail?id=34833. The answer in the link gives you way to work around.
Edit1
public static final int TIME_DIALOG_ID = 1;
public static final int DATE_DIALOG_ID = 2;
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
// set date picker as current date
myDialog = new DatePickerDialog(this, datePickerListener, year, month,day);
break;
case TIME_DIALOG_ID:
//set time picker as current time
myDialog = new TimePickerDialog(this, timePickerListener, hour, minute,false);
break;
}
return myDialog;
}