diff --git a/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java b/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java index 27ae6c2..90282c7 100644 --- a/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java +++ b/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java @@ -245,7 +245,17 @@ protected void setCustomResources(DateTime dateTime, View backgroundView, // Set it if (backgroundResource != null) { - backgroundView.setBackgroundResource(backgroundResource); + try + { + String tmp = this.context.getResources().getResourceName(backgroundResource); + // have resource + backgroundView.setBackgroundResource(backgroundResource); + } + catch(Resources.NotFoundException e) + { + // doesn't have resource, use like color + backgroundView.setBackgroundColor(backgroundResource); + } } } diff --git a/caldroidSampleActivity/src/main/java/com/caldroidsample/CaldroidSampleActivity.java b/caldroidSampleActivity/src/main/java/com/caldroidsample/CaldroidSampleActivity.java index 08ba11a..60e79f4 100644 --- a/caldroidSampleActivity/src/main/java/com/caldroidsample/CaldroidSampleActivity.java +++ b/caldroidSampleActivity/src/main/java/com/caldroidsample/CaldroidSampleActivity.java @@ -106,6 +106,8 @@ public void onSelectDate(Date date, View view) { Toast.makeText(getApplicationContext(), formatter.format(date), Toast.LENGTH_SHORT).show(); + caldroidFragment.setBackgroundResourceForDate(0xffff0000, date); + caldroidFragment.refreshView(); } @Override