Simon Ics Date Picker Dialog throws android.view.InflateException: binary line of XML file # 20: error inflating class net.simonvt.widget.DatePicker

I am using Simon ICS Date Picker Library ( https://github.com/SimonVT ) in my Android app. I have a date button, if I click on this button, a date icon will be displayed in the dialog box. My problem: if I click the button, it does not display the datepicker dialog box, but it displays the following error:

03-02 10:46:59.521: E/AndroidRuntime(911): android.view.InflateException: Binary XML file line #20: Error inflating class net.simonvt.widget.DatePicker 03-02 10:46:59.521: E/AndroidRuntime(911): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 03-02 10:46:59.521: E/AndroidRuntime(911): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) 03-02 10:46:59.521: E/AndroidRuntime(911): at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 03-02 10:46:59.521: E/AndroidRuntime(911): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 03-02 10:46:59.521: E/AndroidRuntime(911): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 03-02 10:46:59.521: E/AndroidRuntime(911): at net.simonvt.app.DatePickerDialog.<init>(DatePickerDialog.java:103) 03-02 10:46:59.521: E/AndroidRuntime(911): at net.simonvt.app.DatePickerDialog.<init>(DatePickerDialog.java:74) @Override protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_PICKER_ID: mCalendar.setTimeInMillis(mStartMillis); year = mCalendar.get(Calendar.YEAR); monthOfYear = mCalendar.get(Calendar.MONTH); dayOfMonth = mCalendar.get(Calendar.DAY_OF_MONTH); return new DatePickerDialog(ListPillBoxActivity.this, startPillBoxDateListener, year, monthOfYear, dayOfMonth); case END_DATE_PICKER_ID: mCalendar.setTimeInMillis(mEndMillis); year = mCalendar.get(Calendar.YEAR); monthOfYear = mCalendar.get(Calendar.MONTH); dayOfMonth = mCalendar.get(Calendar.DAY_OF_MONTH); return new DatePickerDialog(ListPillBoxActivity.this, endPillBoxDateListener, year, monthOfYear, dayOfMonth); } return null; } 

In both cases, the error pointed to the following line:

  return new DatePickerDialog(ListPillBoxActivity.this, startPillBoxDateListener, year, monthOfYear, dayOfMonth); 

all parameters are passed correctly datePickerDialog, but there is a problem in inflating the dialog

Any help appreciated ....

+4
source share
3 answers

I ran into the same problem. The solution is to add three elements to your style, for example, in DatePickerSamples:

 <style name="SampleTheme" parent="@android:style/Theme"> <item name="calendarViewStyle">@style/Widget.Holo.CalendarView</item> <item name="datePickerStyle">@style/Widget.Holo.DatePicker</item> <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> </style> 
+4
source

Based on what @ham said,

after adding these lines as xml resources:

 <style name="SampleTheme" parent="@android:style/Theme"> <item name="calendarViewStyle">@style/Widget.Holo.CalendarView</item> <item name="datePickerStyle">@style/Widget.Holo.DatePicker</item> <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> </style> 

you need to add this attribute to the application tag in AndroidManifest:

 android:theme="@style/SampleTheme" 
+2
source

also do not miss:

 <!-- Copy one of these attributes to your own theme (choose either dark or light). <item name="numberPickerStyle">@style/NPWidget.Holo.NumberPicker</item> <item name="numberPickerStyle">@style/NPWidget.Holo.Light.NumberPicker</item> --> 
0
source

All Articles