Im trying to make something like this
This is what i wanna achieve
How do you achieve the second value and the third value picker ?
Do i need to change to datepicker ?
*EDIT
for the second value i tried this method :
private String[] getDatesFromCalender() {
Calendar c1 = Calendar.getInstance(TimeZone.getTimeZone("GMT+7"));
Calendar c2 = Calendar.getInstance(TimeZone.getTimeZone("GMT+7"));
List<String> dates = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("EE, dd MMM", new Locale("en", "Singapore"));
dates.add(dateFormat.format(c1.getTime()));
for (int i = 0; i < 60; i++) {
c1.add(Calendar.DATE, 1);
dates.add(dateFormat.format(c1.getTime()));
}
c2.add(Calendar.DATE, -60);
for (int i = 0; i < 60; i++) {
c2.add(Calendar.DATE, 1);
dates.add(dateFormat.format(c2.getTime()));
}
return dates.toArray(new String[dates.size() - 1]);
}
then i put this on onCreate
date = getDatesFromCalender();
and set the numberpicker
private void setUpDatePicker() {
npBookingDate.setDisplayedValues(date);
npBookingDate.setMaxValue(date.length - 1);
npBookingDate.setMinValue(0);
npBookingDate.setFormatter(new NumberPicker.Formatter() {
@Override
public String format(int value) {
return date[value];
}
});
}
The result is what i wanted to but it add another date before today check the pict:
Here is what i tried
How to disable dates before today dates ?
OK , for showing two number picker in same dialog, i will post a code snippet as shown below
so , for three number picker, you can add one more number picker view inside the linear layout and attach this view to the dialog fragment, and you can achieve the funtionality