Android : how to change color of textView of custom griditem in android

on Monday, September 15, 2014


I have made a custom calender in android,I have used a custom grid View for this,Now i want to change the color of selected date from the calender,But i don't know how to do this,My code is as below,I am attaching custom grid Item and java code.Please help needed.thank you.


Grid_item



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/calendar_cell"
android:gravity="center"
android:orientation="vertical"
android:padding="2dip" >

<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#545454"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>

<ImageView
android:id="@+id/date_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/dot"
android:visibility="gone" />

</LinearLayout>


code



gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {

((CalendarAdapter) parent.getAdapter()).setSelected(v);
selectedGridDate = CalendarAdapter.dayString.get(position);
String[] separatedTime = selectedGridDate.split("-");
String gridvalueString = separatedTime[2].replaceFirst("^0*",
"");// taking last part of date. ie; 2 from 2012-12-02.
int gridvalue = Integer.parseInt(gridvalueString);
// navigate to next or previous month on clicking offdays.
if ((gridvalue > 10) && (position < 8)) {
setPreviousMonth();
refreshCalendar();
} else if ((gridvalue < 7) && (position > 28)) {
setNextMonth();
refreshCalendar();
}
((CalendarAdapter) parent.getAdapter()).setSelected(v);

showToast(selectedGridDate);

}
});

0 comments:

Post a Comment