Enable and Disable the dates in android

后端 未结 1 1164
南笙
南笙 2021-01-15 06:59

i am using calendar in my application, successfully have implemented calender in my app, but the doubt is how to enable and disable the specific dates(ex: need to enable onl

相关标签:
1条回答
  • 2021-01-15 08:04
        dayView = (TextView) v.findViewById(R.id.date);
            // separates daystring into parts.
            String[] separatedTime = dayString.get(position).split("-");
            // taking last part of date. ie; 2 from 2012-12-02
            String gridvalue = separatedTime[2].replaceFirst("^0*", "");
            // checking whether the day is in current month or not.
            if ((Integer.parseInt(gridvalue) > 1) && (position < firstDay)) {
                // setting offdays to white color.
                dayView.setTextColor(Color.WHITE);
                dayView.setClickable(false);
                dayView.setFocusable(false);
                         float alpha = 0.55f;
                AlphaAnimation alphaUp = new AlphaAnimation(alpha, alpha);
                alphaUp.setFillAfter(true);
                dayView.startAnimation(alphaUp);
    
            } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
                dayView.setTextColor(Color.WHITE);
                dayView.setClickable(false);
                dayView.setFocusable(false);
     float alpha = 0.35f;
                AlphaAnimation alphaUp = new AlphaAnimation(alpha, alpha);
                alphaUp.setFillAfter(true);
                dayView.startAnimation(alphaUp);
                              dayView.setClickable(false);
            } else {
                // setting curent month's days in blue color.
                dayView.setTextColor(Color.BLACK);
                 float alpha = 0.75f;
                AlphaAnimation alphaUp = new AlphaAnimation(alpha, alpha);
                alphaUp.setFillAfter(true);
                dayView.startAnimation(alphaUp);
                              dayView.setClickable(false);
            }
    
    0 讨论(0)
提交回复
热议问题