日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android而一个超级漂亮的日历控件

發(fā)布時(shí)間:2025/7/14 Android 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android而一个超级漂亮的日历控件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

效果


※用法

package com.fancyy.calendarweight;import java.util.ArrayList; import java.util.List;import android.app.Activity; import android.content.Context; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView;import com.fancyy.calendarweight.KCalendar.OnCalendarClickListener; import com.fancyy.calendarweight.KCalendar.OnCalendarDateChangedListener;public class MainActivity extends Activity {String date = null;// 設(shè)置默認(rèn)選中的日期 格式為 “2014-04-05” 標(biāo)準(zhǔn)DATE格式 Button bt;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);bt = (Button) findViewById(R.id.bt);bt.setOnClickListener(new OnClickListener() {public void onClick(View v) {new PopupWindows(MainActivity.this, bt);}});}public class PopupWindows extends PopupWindow {public PopupWindows(Context mContext, View parent) {View view = View.inflate(mContext, R.layout.popupwindow_calendar,null);view.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.fade_in));LinearLayout ll_popup = (LinearLayout) view.findViewById(R.id.ll_popup);ll_popup.startAnimation(AnimationUtils.loadAnimation(mContext,R.anim.push_bottom_in_1));setWidth(LayoutParams.FILL_PARENT);setHeight(LayoutParams.FILL_PARENT);setBackgroundDrawable(new BitmapDrawable());setFocusable(true);setOutsideTouchable(true);setContentView(view);showAtLocation(parent, Gravity.BOTTOM, 0, 0);update();final TextView popupwindow_calendar_month = (TextView) view.findViewById(R.id.popupwindow_calendar_month);final KCalendar calendar = (KCalendar) view.findViewById(R.id.popupwindow_calendar);Button popupwindow_calendar_bt_enter = (Button) view.findViewById(R.id.popupwindow_calendar_bt_enter);popupwindow_calendar_month.setText(calendar.getCalendarYear() + "年"+ calendar.getCalendarMonth() + "月");if (null != date) {int years = Integer.parseInt(date.substring(0,date.indexOf("-")));int month = Integer.parseInt(date.substring(date.indexOf("-") + 1, date.lastIndexOf("-")));popupwindow_calendar_month.setText(years + "年" + month + "月");calendar.showCalendar(years, month);calendar.setCalendarDayBgColor(date,R.drawable.calendar_date_focused); }List<String> list = new ArrayList<String>(); //設(shè)置標(biāo)記列表list.add("2014-04-01");list.add("2014-04-02");calendar.addMarks(list, 0);//監(jiān)聽所選中的日期calendar.setOnCalendarClickListener(new OnCalendarClickListener() {public void onCalendarClick(int row, int col, String dateFormat) {int month = Integer.parseInt(dateFormat.substring(dateFormat.indexOf("-") + 1,dateFormat.lastIndexOf("-")));if (calendar.getCalendarMonth() - month == 1//跨年跳轉(zhuǎn)|| calendar.getCalendarMonth() - month == -11) {calendar.lastMonth();} else if (month - calendar.getCalendarMonth() == 1 //跨年跳轉(zhuǎn)|| month - calendar.getCalendarMonth() == -11) {calendar.nextMonth();} else {calendar.removeAllBgColor(); calendar.setCalendarDayBgColor(dateFormat,R.drawable.calendar_date_focused);date = dateFormat;//最后返回給全局 date}}});//監(jiān)聽當(dāng)前月份calendar.setOnCalendarDateChangedListener(new OnCalendarDateChangedListener() {public void onCalendarDateChanged(int year, int month) {popupwindow_calendar_month.setText(year + "年" + month + "月");}});//上月監(jiān)聽buttonRelativeLayout popupwindow_calendar_last_month = (RelativeLayout) view.findViewById(R.id.popupwindow_calendar_last_month);popupwindow_calendar_last_month.setOnClickListener(new OnClickListener() {public void onClick(View v) {calendar.lastMonth();}});//下月監(jiān)聽buttonRelativeLayout popupwindow_calendar_next_month = (RelativeLayout) view.findViewById(R.id.popupwindow_calendar_next_month);popupwindow_calendar_next_month.setOnClickListener(new OnClickListener() {public void onClick(View v) {calendar.nextMonth();}});//關(guān)閉窗體popupwindow_calendar_bt_enter.setOnClickListener(new OnClickListener() {public void onClick(View v) {dismiss();}});}}}

※Demo下載

http://download.csdn.net/detail/u010785585/7667921



版權(quán)聲明:本文博客原創(chuàng)文章,博客,未經(jīng)同意,不得轉(zhuǎn)載。

轉(zhuǎn)載于:https://www.cnblogs.com/zfyouxi/p/4752790.html

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的Android而一个超级漂亮的日历控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。