我正在开发一个Android应用程序,我想在其中突出显示多个日期。我怎么能用一个简单的CalenderView来做到这一点?
simpleCalendarView = (CalendarView) findViewById(R.id.simpleCalendarView);
Drawable verticalBar = simpleCalendarView.getSelectedDateVerticalBar();
simpleCalendarView.setFocusedMonthDateColor(Color.RED); // set the red color for the dates of focused month
simpleCalendarView.setUnfocusedMonthDateColor(Color.BLUE); // set the yellow color for the dates of an unfocused month
simpleCalendarView.setSelectedWeekBackgroundColor(Color.RED); // red color for the selected week's background
simpleCalendarView.setWeekSeparatorLineColor(Color.GREEN); // green color for the week separator line
// perform setOnDateChangeListener event on CalendarView
simpleCalendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
// display the selected date by using a toast
int y = year;
int m = month + 1;
int d = dayOfMonth;
final String date = d + "/" + m + "/" + y;
final ProgressDialog loading = ProgressDialog.show(Daily_Attendance.this, "Processing...", "Please wait...", false, false);
StringRequest stringRequest = new StringRequest(Request.Method.POST, url3, new Response.Listener() {
@Override
public void onResponse(String response) {
try {
Log.d("rr",response);
loading.dismiss();
JSONArray j = new JSONArray(response);
JSONObject jo = j.getJSONObject(0);
String res = jo.getString("result");
if (res.equals("true")) {
alert.setMessage("You Were Present on " + date)
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.show();
}
if (res.equals("false")) {
alert.setMessage("You were Absent on " + date)
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
})
AppController.getInstance().addToRequestQueue(stringRequest);
}
});