• 冲刺(七)


    日历部分的代码:

    package com.example.twj.qiandao;
    
    import java.util.Calendar;
    
    /**
     * 专用日历
     * Created by t'w'j on 2020/4/21.
     */
    public class SpecialCalendar {
    
        /**
         * 判断是否是闰年
         */
        public boolean isLeapYear(int year){
    
            if(year%100==0&&year%400==0){
                return true;
            }else if(year%100!=0&&year%4==0){
                return true;
            }
            return false;
        }
        /**
         * 1 3 5 7 8 10 12,三十一天
         * 4 6 9 11,三十天
         * 2,二十八天
         * 闰年29天
         */
        public int getDaysOfMonth(boolean isLeapYear,int month){
            int days=0;
            switch (month){
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    days=31;
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    days=30;
                    break;
                case 2:
                    if(isLeapYear){
                        days=29;
                    }else {
                        days=28;
                    }
            }
            return days;
        }
        /**
         * 得到某年某月1号是星期几
         */
        public int getWeekdayOfMonth(int mYear,int mMonth){
            Calendar cal=Calendar.getInstance();
            cal.set(mYear,mMonth,1);
            return cal.get(Calendar.DAY_OF_WEEK)-1;
        }
    
    
    }
    package com.example.twj.qiandao;
    
    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.RelativeLayout;
    
    /**
     * 自定义RelativeLayout正方形
     * Created by t'w'j on 2020/4/21.
     */
    public class SquareRelativeLayout extends RelativeLayout {
    
        public SquareRelativeLayout(Context context) {
            super(context);
        }
    
        public SquareRelativeLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public SquareRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }
    
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));
            //Children are just made to fill our space
            int childWithSize=getMeasuredWidth();
            //高度和宽度一样
            heightMeasureSpec=widthMeasureSpec=MeasureSpec.makeMeasureSpec(childWithSize,MeasureSpec.EXACTLY);
    
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }
  • 相关阅读:
    javascript高级编程笔记03(正则表达式)
    javascript高级编程笔记02(基本概念)
    javascript高级编程笔记01(基本概念)
    ExtJS4加载FormPanel数据的几种方式
    Extjs 更新数据集Ext.PagingToolbar的start参数重置的处理
    四川绵阳 晴
    四川绵阳 阴
    四川绵阳 晴
    在IntelliJ IDEA中添加repository模板
    List分组 用于客服对话分组场景
  • 原文地址:https://www.cnblogs.com/tianwenjing123-456/p/12748423.html
Copyright © 2020-2023  润新知