Illegal argument exception in android dialog

前端 未结 4 1484
礼貌的吻别
礼貌的吻别 2021-01-18 07:34

i am using this code to show alert dialog...when i click on the ok button it should show the date picker..

protected Dialog onCreateDialog(int id) {
    swit         


        
相关标签:
4条回答
  • 2021-01-18 07:57

    you must have changed mYear, mMonth, mDay values. months are 0-11. make sure your values are in the range

    0 讨论(0)
  • 2021-01-18 07:58

    Do you know that month field is zero based - starts from zero? Make sure that value for month does not exceed 11! I was getting exactly the same message and since I used 12 for a month, that was the reason to get this exception.

    0 讨论(0)
  • 2021-01-18 08:13

    As indicated by the error you see in the logs, one of your mYear, mMonth or mDay values is invalid.

    0 讨论(0)
  • 2021-01-18 08:14

    an idea to set the month field value to X is to set it to X % 12 (modulo), so then you are sure that you will not exceed the autorized value. Same for hours and minutes. Cheers. Charles.

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