※效果

※用法

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;// 设置默认选中的日期  格式为 “2014-04-05” 标准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>(); //设置标记列表list.add("2014-04-01");list.add("2014-04-02");calendar.addMarks(list, 0);//监听所选中的日期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//跨年跳转|| calendar.getCalendarMonth() - month == -11) {calendar.lastMonth();} else if (month - calendar.getCalendarMonth() == 1 //跨年跳转|| month - calendar.getCalendarMonth() == -11) {calendar.nextMonth();} else {calendar.removeAllBgColor(); calendar.setCalendarDayBgColor(dateFormat,R.drawable.calendar_date_focused);date = dateFormat;//最后返回给全局 date}}});//监听当前月份calendar.setOnCalendarDateChangedListener(new OnCalendarDateChangedListener() {public void onCalendarDateChanged(int year, int month) {popupwindow_calendar_month.setText(year + "年" + month + "月");}});//上月监听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();}});//下月监听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();}});//关闭窗体popupwindow_calendar_bt_enter.setOnClickListener(new OnClickListener() {public void onClick(View v) {dismiss();}});}}}

※Demo下载

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

版权声明:本文博客原创文章,博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/zfyouxi/p/4752790.html

Android而一个超级漂亮的日历控件相关推荐

  1. html页面美化代码时间,CSS+JS美化过漂亮的日历控件

    CSS+JS美化过漂亮的日历控件 - www.webdm.cn var months = new Array("一", "二", "三",& ...

  2. CalendarView使用详细文档(一个很不错的日历控件)

    github地址:https://github.com/huanghaibin-dev/CalendarView CalendarView使用详细文档 日历控件定制是移动开发平台上比较常见的而且比较难 ...

  3. 一个强大的js日历控件 FullCalendar 外加一堆可以直接运行的测试代码拿走不谢

    资料地址 FullCalendar官网地址 FullCalendar文档 FullCalendar-v5.5.1在下地址 FullCalendar测试实例免费下载地址: https://downloa ...

  4. Android做一个显示电量的小控件

    1.目录结构,本人是使用安卓死丢丢. 2.运行界面,输入框中输入数值,点击刷新,会再电池中显示出相应的电量 3.绘制自定义电池控件,首先,新建一个类BatteryState继承View private ...

  5. android组合控件的焦点,撸一个简单的TV版焦点控制的日历控件

    1.效果 最近需求要一个遥控控制的日历控件,找了半天没找到轮子,就自己撸一个,先看效果图: 效果图.gif 2.XML属性,所有属性默认为效果图 calender_textSize:星期和日期的字体大 ...

  6. android 固定底部 布局_Android系统列表控件

    在android系统控件中,有多个控件可以展示列表数据. 一.ListView 该组件是android中最常用的一个UI组件,用于实现在屏幕上显示多个内容,以便于我们用手指进行滑动. ListView ...

  7. android listview添加数据_Android系统列表控件

    在android系统控件中,有多个控件可以展示列表数据. 一.ListView 该组件是android中最常用的一个UI组件,用于实现在屏幕上显示多个内容,以便于我们用手指进行滑动. ListView ...

  8. excel日历弄到html,如何在Excel中利用日历控件来快速输入日期

    给大家分享了一个利用日历控件在Excel单元格中输入日期的小窍门.大家知道,物流和会计行业的报表,经常需要手工输入一些日期,例如发货日期,在途时间.到达配送中心日期.签收日期等,如果手工输入,难免出错 ...

  9. 日历控件FullCalendar中文API

    1. 使用方式, 引入相关js, css后, $('#div_name').fullCalendar({//options});  接受的是一个option对象 2. 普通属性 2.1. year, ...

最新文章

  1. (转)android 在电脑上显示真机屏幕
  2. 工业控制软件测试评价体系,工业控制信息安全产品测试评价的体系.doc
  3. Win10 配置 TensorFlow-gpu 深度学系框架
  4. 用dreamweaver cs6快速布局后台架构_后台系统:产品设计 | 七步法
  5. 没有还款日期的借条会永久有效吗?
  6. poj 3026 Borg Maze (最小生成树+bfs)
  7. codevs——2152 滑雪
  8. TLS certificate verification has been disabled
  9. C# UrlEncoding
  10. mysql 是否有归档模式_数据库的归档模式和非归档模式的区别
  11. 检测网站CDN是否生效
  12. 报告解读下载 | 7月《中国数据库行业分析报告》重磅发布!精彩抢先看!
  13. 流放者柯南服务器文件,《流放者柯南》个人服务器架设教程文本及视频详解
  14. QT编译出错解决 libQtCore.so: undefined reference to `QInotifyFileSystemWatcherEngine::create()'
  15. 8.openCV 裁剪图像
  16. AC Dream1069
  17. JavaScript 验证码制作
  18. 上帝视角学JAVA- 基础07-类05【2021-08-06】
  19. golang的检测并发访问共享资源是否有问题的工具--race detetor
  20. 当当网畅销书排行爬虫(requests+BeautifulSoup)

热门文章

  1. 发送语音+讯飞翻译 项目案例
  2. 计数排序,基数排序,桶排序
  3. javascript写计数器
  4. 文件监视器——Filemon
  5. 数据科学家常用的十大机器学习算法,都在这了!
  6. 评估指标:ROC,AUC,Precision、Recall、F1-score
  7. table中head表头固定,body滚动
  8. Swift的控制转移语句-- fallthrough语句
  9. Linux系统简介 、 安装Linux系统 、 RHEL6基本操作
  10. 传智播客视频学习 ---- 字符串含义( C 语言中)