Skip to content

Commit

Permalink
Added posibility of using selectors as backgrounds for specific dates
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmash committed Feb 26, 2015
1 parent 517203c commit 6b22ca6
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -280,6 +288,7 @@ protected void customizeTextView(int position, TextView cellView) {
}

cellView.setTextColor(CaldroidFragment.selectedTextColor);
cellView.addOnLayoutChangeListener(onLayoutChangeListener);
} else {
shouldResetSelectedView = true;
}
Expand Down

1 comment on commit 6b22ca6

@madsmash
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try to use a selector as a background for specific dates in order to get a special background when that date is selected, you'll see that it's not possible. First I tried by using cellView.setSelected(true) but this doesn't help since android has it's own bug that removes that state before the view is drawn, more info here: http://stackoverflow.com/questions/12545302/gridview-adapter-getview-does-not-set-selected-state-properly

Please sign in to comment.