From 6b22ca6c2e14f7aca213e63ed839c1f1bf3d6307 Mon Sep 17 00:00:00 2001 From: Felipe Martinez Date: Thu, 26 Feb 2015 18:21:59 +0100 Subject: [PATCH] Added posibility of using selectors as backgrounds for specific dates --- .../java/com/roomorama/caldroid/CaldroidGridAdapter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java b/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java index d569f69..f00a59c 100644 --- a/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java +++ b/caldroid/src/main/java/com/roomorama/caldroid/CaldroidGridAdapter.java @@ -220,6 +220,14 @@ protected void setCustomResources(DateTime dateTime, View backgroundView, } } + View.OnLayoutChangeListener onLayoutChangeListener = new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { + v.setSelected(true); + v.removeOnLayoutChangeListener(this); + } + }; + /** * Customize colors of text and background based on states of the cell * (disabled, active, selected, etc) @@ -280,6 +288,7 @@ protected void customizeTextView(int position, TextView cellView) { } cellView.setTextColor(CaldroidFragment.selectedTextColor); + cellView.addOnLayoutChangeListener(onLayoutChangeListener); } else { shouldResetSelectedView = true; }