Thursday, 12 September 2013

Color today date on calendar

Color today date on calendar

I have an example of Calendar in android. In the beginning all dates have
light gray background, only today date have blue background. When I press
another date, it turns into blue. I want that today date keeps dark gray
background when I press another date. How can I do this?
Part of CalendarAdapter.java
if (dayString.get(position).equals(curentDateString)) { //Turns today
date into blue when started
setSelected(v);
previousView = v;
} else {
v.setBackgroundResource(R.drawable.list_item_background);
}
list_item_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/calendar_cel_selectl"
android:state_pressed="true" />
<item
android:drawable="@drawable/calendar_cel_selectl"
android:state_focused="true" />
<item
android:drawable="@drawable/calendar_cell" />
</selector>

No comments:

Post a Comment