How to restrict user not to select future date from calender view in android -


I have to restrict the calendar to choose from the calendar view from the future date. It can either be an error message or another method that can help with the future date selection. Please feel free to teach me

  cv = (CalendarView) findViewById (R.id.calendarView1). CV.setOnDateChangeListener (New OnDateChangeListener) {@Override Public Zero onSelectedDayChange (CalendarView to view, integer year, integer month, integer dayOfMonth) {// TODO auto-created method stub cvSTR = dayOfMonth + ":" + + (Month +1 ) + ': "+ Years; Toast.makeText (getBaseContext)," is the selected date \ n \ n "+ cvSTR, toast.LENGTH_SHORT) .show (); MyDay = String.valueOf (dayOfMonth); MyMonth = String ValueOf (month + 1); Mayer = string.value (year);}});  

Add this:

  date maxDate = new date (); // set your maximum date Cv.maxdate (maxDate.getTime ());  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -