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; }