android - CalendarView getDate method returns current date, not selected date... What am I doing wrong? -
my calendarview fails return selected date, instead returning default points today.
i of course changing date selected in calendar, , indeed displays having changed. tried inspecting view in debug mode, didn't find anything.
i running in simulator, not on real phone... should modify settings? missing important? because confusing i'm not getting selected date, current one.
<calendarview android:id="@+id/view_calendar_create_event_date" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1" />
this called event listener
protected void createevent(view view){ textview eventnameview = (textview) this.findviewbyid(r.id.createeventnameinput); string eventname = eventnameview.geteditabletext().tostring(); calendarview eventoccursonview = (calendarview) this.findviewbyid(r.id.view_calendar_create_event_date); long eventoccurson = eventoccursonview.getdate(); date temporary = new date(eventoccurson); event newevent = new event(eventname, "", 0, 0, eventoccurson); newevent.save(view.getcontext()); }
and how i'm setting event listener
savebutton.setonclicklistener(new view.onclicklistener(){ @override public void onclick(view view) { // create event eventdetailsactivity.this.createevent(view); // notify user snackbar.make(view, "successfully created new event!", snackbar.length_long) .setaction("action", null).show(); // return previous activity finish(); } });
you need implement setondatechangelistener
long eventoccurson; eventoccursonview.setondatechangelistener(new ondatechangelistener() { //show selected date toast @override public void onselecteddaychange(calendarview view, int year, int month, int day) { toast.maketext(getapplicationcontext(), day + "/" + month + "/" + year, toast.length_long).show(); calendar c = new calendar.getinstance(); c.set(year, month, day); eventoccurson= c.gettimeinmillis(); //this want use later } });
Comments
Post a Comment