Android, is there any way to disable writing inside a date picker using keyboard?

后端 未结 4 1853
忘了有多久
忘了有多久 2021-02-19 06:56

Is there any way to disable writing inside a date picker using keyboard? As I just want the plus and minus signs to be used to set the date. thanks in advance.

相关标签:
4条回答
  • 2021-02-19 07:05
    myDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
    
    0 讨论(0)
  • 2021-02-19 07:05
    Calendar start = Calendar.getInstance();
    
                int Year = DatePicker.getYear();
                int Month = DatePicker.getMonth();
                int Day = DatePicker.getDayOfMonth();
    
                start.set(Year, Month, Day);
        //      DayDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
    
                Date periodDate = start.getTime();
                int daysToAdd = 280;
                Calendar cal = Calendar.getInstance();
    
    cal.add(Calendar.DAY_OF_MONTH,daysToAdd );
                System.err.println("-----" +cal.getTime());
                int AfterCalc = cal.getTime().getYear()+1900;
                System.err.println("-----" + AfterCalc);
                int AfterCalc2 = cal.getTime().getMonth();
                System.err.println("----" + AfterCalc2);
    
    0 讨论(0)
  • 2021-02-19 07:09

    Best option for stopping manual editing in DatePickerDialog items is using set the descendantFocusability . You can add it in code or in your dialog style file.

    Here is the implementation using style

    0 讨论(0)
  • 2021-02-19 07:13
    dp.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
    

    is the best way to do so.

    You can check this also

    Focusable EditText inside ListView

    0 讨论(0)
提交回复
热议问题