安卓日历开发源代码.docx

上传人:b****5 文档编号:4705834 上传时间:2022-12-07 格式:DOCX 页数:33 大小:25.18KB
下载 相关 举报
安卓日历开发源代码.docx_第1页
第1页 / 共33页
安卓日历开发源代码.docx_第2页
第2页 / 共33页
安卓日历开发源代码.docx_第3页
第3页 / 共33页
安卓日历开发源代码.docx_第4页
第4页 / 共33页
安卓日历开发源代码.docx_第5页
第5页 / 共33页
点击查看更多>>
下载资源
资源描述

安卓日历开发源代码.docx

《安卓日历开发源代码.docx》由会员分享,可在线阅读,更多相关《安卓日历开发源代码.docx(33页珍藏版)》请在冰豆网上搜索。

安卓日历开发源代码.docx

安卓日历开发源代码

xmlversion="1.0"encoding="utf-8"?

>

android=""

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

orientation="vertical">

android:

id="@+id/lay_title"

style="@style/TitleStyle"

android:

layout_width="fill_parent">

android:

id="@+id/btn_back"

style="@style/TitleLeftButtonStyle"/>

android:

id="@+id/tv_top"

style="@style/TitleMiddleTextStyle"

android:

text="请选择日期"/>

android:

id="@+id/btn_goback_to_today"

style="@style/TitleRightButtonStyle"

android:

text="今天"/>

android:

layout_width="fill_parent"

android:

layout_height="53.0dip"

android:

background="#ff394147"

android:

gravity="center_vertical">

android:

id="@+id/btn_prev_month"

android:

layout_width="0.0dip"

android:

layout_height="fill_parent"

android:

layout_weight="0.2"

android:

gravity="center"

android:

orientation="vertical">

android:

id="@+id/left_img"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

background="@drawable/triangle06_states"

android:

duplicateParentState="true"

android:

text=""

android:

textSize="16.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="fill_parent"

android:

layout_weight="0.6"

android:

gravity="center"

android:

orientation="vertical">

android:

id="@+id/tv_month"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

gravity="center"

android:

text="xxxx年14月"

android:

textColor="#ffffffff"

android:

textSize="21.0dip"/>

android:

id="@+id/btn_next_month"

android:

layout_width="0.0dip"

android:

layout_height="fill_parent"

android:

layout_weight="0.2"

android:

gravity="center"

android:

orientation="vertical">

android:

id="@+id/right_img"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

background="@drawable/triangle05_states"

android:

duplicateParentState="true"

android:

text=""

android:

textSize="16.0dip"/>

android:

layout_width="fill_parent"

android:

layout_height="22.0dip"

android:

background="#ff8091a8">

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周日"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周一"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周二"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周三"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周四"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周五"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

android:

layout_width="0.0dip"

android:

layout_height="wrap_content"

android:

layout_gravity="center"

android:

layout_weight="1.0"

android:

gravity="center"

android:

text="周六"

android:

textColor="#ffffffff"

android:

textSize="14.0dip"/>

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

if(schDateTagFlag[i]==position){

//设置日程标记背景

textView.setBackgroundResource(R.drawable.mark);

}

}

}

if(currentFlag==position){

//设置当天的背景

drawable=res.getDrawable(R.drawable.current_day_bgc);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 艺术

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1