I want to pass the data from the API (called using Retrofit) to calendar date onClick() event (onSelectedDayChange).
public class MainActivity extends AppCompatActivity {
List<APIData> dataList;
private CalendarView mCalendarView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mCalendarView= findViewById(R.id.calendarView);
Calendar rightNow = Calendar.getInstance();
mCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
month = 1+month;
Toast.makeText(getApplicationContext(), ""+year+"-"+month+"-"+dayOfMonth,Toast.LENGTH_SHORT).show();
}
});
APIInterface apiInterface = APIClient.getClient().create(APIInterface.class);
Call<APIData> call = apiInterface.gethistorydetails("s10-1", "2018-08-01");
call.enqueue(new Callback<APIData>() {
@Override
public void onResponse(Call<APIData> call, Response<APIData> response) {
Log.d("TAG",response.code()+"");
APIData apiData = response.body();
}
@Override
public void onFailure(Call<APIData> call, Throwable t) {
}
});
}
}
As you can see in this pic, there are 4 different fields where I need to show data called from API. So whenever I click any dates on the calendar, the respective data from API should fill up the fields.