Open vipulasri opened 7 years ago
weekdaysDataSource..setSelectedDays(int[2,3,4])//Use an array with Calendar class constants like Calendar.MONDAY
Check out the sample code for how to implement W-B-B in various ways https://github.com/TouchBoarder/weekdays-buttons-bar/blob/master/sample/src/main/java/com/touchboarder/weekdaysdemo/MainActivity.java
I am doing the same thing, but the selected weekdays are different:
if(child.getTimings()!=null && child.getTimings().size()>0){
int[] ret = new int[child.getTimings().size()];
for (int i=0; i < ret.length; i++) {
switch (child.getTimings().get(i).getWeekday()) {
case "Sunday":
ret[i] = Calendar.SUNDAY;
break;
case "Monday":
ret[i] = Calendar.MONDAY;
break;
case "Tuesday":
ret[i] = Calendar.TUESDAY;
break;
case "Wednesday":
ret[i] = Calendar.WEDNESDAY;
break;
case "Thursday":
ret[i] = Calendar.THURSDAY;
break;
case "Friday":
ret[i] = Calendar.FRIDAY;
break;
case "Saturday":
ret[i] = Calendar.SATURDAY;
break;
}
}
Log.e("timings","->"+ Arrays.toString(ret));
mWeekdaysDataSource.setSelectedDays(ret);
Please take a look at how this is implemented in the source code: getDays() https://github.com/TouchBoarder/weekdays-buttons-bar/blob/master/module/src/main/java/com/touchboarder/weekdaysbuttons/WeekdaysDataSource.java
how can i dynamically set values in
setSelectedDays(int... days)
by getting ids stored in list?