android:
id="@+id/gridview"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
background="#00000000"
android:
clickable="true"
android:
clipChildren="true"
android:
columnWidth="55.0dip"
android:
horizontalSpacing="1.0dip"
android:
listSelector="@null"
android:
numColumns="7"
android:
paddingBottom="1.0dip"
android:
stretchMode="columnWidth"
android:
verticalSpacing="1.0dip"/>
】
xmlversion="1.0"encoding="utf-8"?
>
xmlns:
android="/apk/res/android"
android:
background="#FFFFFF"
android:
layout_width="fill_parent"
android:
layout_height="fill_parent">
android:
gravity="center"
android:
layout_width="46dp"
android:
layout_height="55dp"
android:
id="@+id/tvtext"
/>
32px;color:
#ff0000;">
/**
*日历gridview中的每一个item显示的textview
*@authorlmw
*
*/
publicclassCalendarAdapterextendsBaseAdapter{
privatebooleanisLeapyear=false;//是否为闰年
privateintdaysOfMonth=0;//某月的天数
privateintdayOfWeek=0;//具体某一天是星期几
privateintlastDaysOfMonth=0;//上一个月的总天数
privateContextcontext;
privateString[]dayNumber=newString[42];//一个gridview中的日期存入此数组中
//privatestaticStringweek[]={"周日","周一","周二","周三","周四","周五","周六"};
privateSpecialCalendarsc=null;
privateLunarCalendarlc=null;
privateResourcesres=null;
privateDrawabledrawable=null;
privateStringcurrentYear="";
privateStringcurrentMonth="";
privateStringcurrentDay="";
privateSimpleDateFormatsdf=newSimpleDateFormat("yyyy-M-d");
privateintcurrentFlag=-1;//用于标记当天
privateint[]schDateTagFlag=null;//存储当月所有的日程日期
privateStringshowYear="";//用于在头部显示的年份
privateStringshowMonth="";//用于在头部显示的月份
privateStringanimalsYear="";
privateStringleapMonth="";//闰哪一个月
privateStringcyclical="";//天干地支
//系统当前时间
privateStringsysDate="";
privateStringsys_year="";
privateStringsys_month="";
privateStringsys_day="";
publicCalendarAdapter(){
Datedate=newDate();
sysDate=sdf.format(date);//当期日期
sys_year=sysDate.split("-")[0];
sys_month=sysDate.split("-")[1];
sys_day=sysDate.split("-")[2];
}
publicCalendarAdapter(Contextcontext,Resourcesrs,intjumpMonth,intjumpYear,intyear_c,intmonth_c,intday_c){
this();
this.context=context;
sc=newSpecialCalendar();
lc=newLunarCalendar();
this.res=rs;
intstepYear=year_c+jumpYear;
intstepMonth=month_c+jumpMonth;
if(stepMonth>0){
//往下一个月滑动
if(stepMonth%12==0){
stepYear=year_c+stepMonth/12-1;
stepMonth=12;
}else{
stepYear=year_c+stepMonth/12;
stepMonth=stepMonth%12;
}
}else{
//往上一个月滑动
stepYear=year_c-1+stepMonth/12;
stepMonth=stepMonth%12+12;
if(stepMonth%12==0){
}
}
currentYear=String.valueOf(stepYear);;//得到当前的年份
currentMonth=String.valueOf(stepMonth);//得到本月(jumpMonth为滑动的次数,每滑动一次就增加一月或减一月)
currentDay=String.valueOf(day_c);//得到当前日期是哪天
getCalendar(Integer.parseInt(currentYear),Integer.parseInt(currentMonth));
}
publicCalendarAdapter(Contextcontext,Resourcesrs,intyear,intmonth,intday){
this();
this.context=context;
sc=newSpecialCalendar();
lc=newLunarCalendar();
this.res=rs;
currentYear=String.valueOf(year);;//得到跳转到的年份
currentMonth=String.valueOf(month);//得到跳转到的月份
currentDay=String.valueOf(day);//得到跳转到的天
getCalendar(Integer.parseInt(currentYear),Integer.parseInt(currentMonth));
}
@Override
publicintgetCount(){
//TODOAuto-generatedmethodstub
returndayNumber.length;
}
@Override
publicObjectgetItem(intposition){
//TODOAuto-generatedmethodstub
returnposition;
}
@Override
publiclonggetItemId(intposition){
//TODOAuto-generatedmethodstub
returnposition;
}
@Override
publicViewgetView(intposition,ViewconvertView,ViewGroupparent){
if(convertView==null){
convertView=LayoutInflater.from(context).inflate(R.layout.calendar_item,null);
}
TextViewtextView=(TextView)convertView.findViewById(R.id.tvtext);
Stringd=dayNumber[position].split("\\.")[0];
Stringdv=dayNumber[position].split("\\.")[1];
SpannableStringsp=newSpannableString(d+"\n"+dv);
sp.setSpan(newStyleSpan(android.graphics.Typeface.BOLD),0,d.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sp.setSpan(newRelativeSizeSpan(1.2f),0,d.length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
if(dv!
=null||dv!
=""){
sp.setSpan(newRelativeSizeSpan(0.75f),d.length()+1,dayNumber[position].length(),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
//sp.setSpan(newForegroundColorSpan(Color.MAGENTA),14,16,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
textView.setText(sp);
textView.setTextColor(Color.GRAY);
//if(position<7){
////设置周
//textView.setTextColor(Color.WHITE);
//textView.setBackgroundColor(color.search_txt_color);
//textView.setTextSize(14);
//}
if(position=dayOfWeek){
//当前月信息显示
textView.setTextColor(Color.BLACK);//当月字体设黑
drawable=res.getDrawable(R.drawable.current_day_bgc);
}
if(schDateTagFlag!
=null&&schDateTagFlag.length>0){
for(inti=0;iif(schDateTagFlag[i]==position){
//设置日程标记背景
textView.setBackgroundResource(R.drawable.mark);
}
}
}
if(currentFlag==position){
//设置当天的背景
drawable=res.getDrawable(R.drawable.current_day_bgc);