This is my code time view and date view. how to I will be the select date then set the current time and disable past time..and next date will be select all time will enable how to possible these options how to write this code, anybody help, how to disable past time on time picker in android using the calendar
public void CalenderView() {
/* ends after 1 month from now */
Calendar endDate = Calendar.getInstance();
endDate.add( Calendar.DAY_OF_WEEK_IN_MONTH, 1 );
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder( this, R.id.calendarView )
.range( Calendar.getInstance(), endDate )
.datesNumberOnScreen( 5 )
.configure()
.formatTopText( "EEE" )
.formatMiddleText( "dd" )
.showBottomText( false )
.end()
.build();
horizontalCalendar.getConfig()
.setSizeTopText( (float) 12 )
.setSizeMiddleText( (float) 25 );
horizontalCalendar.setCalendarListener( new HorizontalCalendarListener() {
@Override
public void onDateSelected(Calendar date, int position) {
}
} );
}
public void TimePickerView(){
//Get the widgets reference from XMLayout
final TextView tv = (TextView) findViewById(R.id.tv);
tp = (TimePicker) findViewById(R.id.tp);
Button btn = (Button) findViewById(R.id.btn);
//Set the TextView text color
tv.setTextColor(Color.parseColor("#b601fd"));
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int hourOfDay = tp.getCurrentHour(); //Get TimePicker current hour
int minute = tp.getCurrentMinute(); //Get TimePicker current minute
//Display the TimePicker current time to app interface
String AMPM = "AM";
if(hourOfDay>11)
{
//Get the current hour as AM PM 12 hour format
hourOfDay = hourOfDay-12;
AMPM = "PM";
}
tv.setText("" + hourOfDay + ":" + minute + ":" + AMPM);
}
});