I am new to android.
I am using a CalendarPickerView as an activity to select a range of dates.
All I want to do is to is to pass the first and the last day selected to a textview in another activity.
Right now I have a CalendarPickerActivity which you can see below (the code) then I have another activity called EventFiltersActivity where I have a TextView which is supposed to show the first day and the last day selected
Thanks already for your patience and help.
public class CalendarPickerActivity extends AppCompatActivity {
private CalendarPickerView calendar;
Button saveButton;
Button clearButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_calendar_picker);
saveButton = (Button) findViewById(R.id.save_button);
clearButton = (Button) findViewById(R.id.resetta_button);
final Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 10);
final Calendar lastYear = Calendar.getInstance();
lastYear.add(Calendar.YEAR, -10);
calendar = (CalendarPickerView) findViewById(R.id.calendar_picker);
final ArrayList<Integer> list = new ArrayList<>();
list.add(2);
calendar.getSelectedDates();
calendar.init(lastYear.getTime(), nextYear.getTime()) //
.inMode(CalendarPickerView.SelectionMode.RANGE)
.withSelectedDate(Calendar.getInstance().getTime());
//.withDeactivateDates(list);
//.withHighlightedDates(arrayList);
calendar.setOnDateSelectedListener(new CalendarPickerView.OnDateSelectedListener() {
@Override
public void onDateSelected(Date date) {
Toast.makeText(getApplicationContext(), "Selected Date is : " + date.toString(), Toast.LENGTH_SHORT).show();
}
@Override
public void onDateUnselected(Date date) {
}
});
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), EventFiltersActivity.class);
calendar.getSelectedDates();
}
});
}
}