我有一个列表视图,它意味着根据用户在水平日历视图中选择的星期几显示不同的列表项。
从mon-sat我想在循环器视图中显示四个列表项,然后在星期日显示两个项目,其价值不同于前四个mon-sat的值。
我遇到的问题是,当我选择星期日时,我想要显示两个列表项,但它显示了来自mon-sat值的前两个项的值。
mAppointmentList.add(new Appointment("8:00AM", "11:00AM","Book"));
mAppointmentList.add(new Appointment("11:00AM", "2:00PM" ,"Book"));
mAppointmentList.add(new Appointment("2:00PM", "5:00PM" ,"Book"));
mAppointmentList.add(new Appointment("5:00PM", "8:00PM" ,"Book"));
然后在星期天这个
mAppointmentList.add(new Appointment("1:00PM", "4:00PM" ,"Book"));
mAppointmentList.add(new Appointment("4:00PM", "7:00PM" ,"Book"));
星期天 image for sun
当前代码:
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.startDate(startDate.getTime())
.endDate(endDate.getTime())
.build();
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
@Override
public void onDateSelected(Date date, int position) {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd MMM yyyy", Locale.ENGLISH);
SimpleDateFormat dayFormat = new SimpleDateFormat("EEE", Locale.ENGLISH);
mDate = date;
currentDate = dateFormat.format(date);
String day = dayFormat.format(date);
if (day.equals("Sun")){
mAppointmentList.clear();
mAppointmentList.add(new Appointment("1:00PM", "4:00PM" ,"Book"));
mAppointmentList.add(new Appointment("4:00PM", "7:00PM" ,"Book"));
} else {
mAppointmentList.clear();
mAppointmentList.add(new Appointment("8:00AM", "11:00AM","Book"));
mAppointmentList.add(new Appointment("11:00AM", "2:00PM" ,"Book"));
mAppointmentList.add(new Appointment("2:00PM", "5:00PM" ,"Book"));
mAppointmentList.add(new Appointment("5:00PM", "8:00PM" ,"Book"));
}
}
@Override
public void onCalendarScroll(HorizontalCalendarView calendarView,
int dx, int dy) {
}
@Override
public boolean onDateLongClicked(Date date, int position) {
return true;
}
});
答案 0 :(得分:0)
请使用ListView视图持有者模式,按照link。
更新数据时,请不要忘记致电import { defineLocale } from 'ngx-bootstrap/chronos';
import { ptBrLocale } from 'ngx-bootstrap/locale';
defineLocale('pt-br', ptBrLocale);
。