Skip to content Skip to sidebar Skip to footer

Enable And Disable The Dates In Android

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 only monda

Solution 1:

    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);
        }

Post a Comment for "Enable And Disable The Dates In Android"