Android custom calendar view disable specific dates

后端 未结 2 1427
暗喜
暗喜 2021-01-22 16:54

i\'m new to android developing and started to develop an booking app. There is a calendar view and i want to disable booked dates in that calendar. I found out that disabling fe

2条回答
  •  青春惊慌失措
    2021-01-22 17:46

    i have faced the same problem using custom calendar ,
    i just overridden the function of adapter 
    
    
     @Override
        public boolean isEnabled(int position) {
             if(mySet.contains(position))
                return true;
            else
                return false;
        }
    
    
    then i call the function int the adapter view 
    
     isEnabled(position);
    
    
    
    
    befoer that tale Hashset and add the position which is displaying the calanderview 
    
    
               // mysetSize=set.size();
                //isEnabled(Integer.parseInt(gridvalue));
                Log.d(dayView.getTag()+"------1-------"+gridvalue,"-------"+position);
            } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
                dayView.setTextColor(Color.WHITE);
                dayView.setClickable(false);
                dayView.setFocusable(false);
                Log.d("-------mySet------","-------"+mySet);
                Log.d(mysetSize+"-------28------"+gridvalue,"-------"+position);
                set.add(position);
    
            } else {
                // setting curent month's days in blue color.
                dayView.setTextColor(Color.DKGRAY);
                Log.d(dayView.getTag()+"-------current display post------","-------"+position);
                mySet.add(position);
            }
    

提交回复
热议问题