I want to select multiple dates in calendar,multiple select is working fine but in toast displaying only single date(first date).If I selected 4 days(1.8.14 to 4.8.14) all
Try below code for briefly explanation.......
final Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 2);
gson = new Gson();
sharedpreferences1 = getSharedPreferences("MyPREFERENCES10005471hjsdhjsdjghjfdjksdlsasa00fdsadeetytadsadsywrerwerrw0255878762343", Context.MODE_PRIVATE);
editor = sharedpreferences1.edit();
calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
final String ffffd=sharedpreferences1.getString("Str",null);
sdf = new SimpleDateFormat("dd-MM-yyyy");
Type type = new TypeToken>() {}.getType();
arrayList = gson.fromJson(ffffd, type);
dates = new ArrayList();
if(arrayList!=null){
Toast.makeText(SampleTimesSquareActivity.this, "" + arrayList, LENGTH_SHORT).show();
calendar.init(new Date(), nextYear.getTime()) //
.inMode(SelectionMode.MULTIPLE) //
.withSelectedDates(arrayList);
for(int ii=0;ii) calendar.getSelectedDates();
String json=null;
Log.i("Size",""+dates);
for (int i = 0; i < dates.size(); i++) {
Date tempDate = dates.get(i);
String formattedDate = sdf.format(tempDate);
Toast.makeText(SampleTimesSquareActivity.this, "" + formattedDate, LENGTH_SHORT).show();
json = gson.toJson(dates);
}
editor.putString("Str", json);
editor.clear();
editor.apply();
}
});
Thanks...take enjoy