问题描述
我正在使用Simon的ICS日期选择器库( https://github.com/SimonVT ) android应用.我有一个日期按钮,如果单击该按钮,它将在对话框中显示ics datepicker.我的问题是,如果单击按钮,它不会显示日期选择器对话框,但显示以下错误:
I'm using Simon's ICS Date Picker Library (https://github.com/SimonVT) in my android app.I have a date button, if I make click on that button, it will show ics datepicker in dialog.My Issue is, if I click on button, it doesn't show datepicker dialog, but it shows following error as :
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;
}
在两种情况下,Bug都指向以下一行:
Bug pointed towards the following line on both cases :
return new DatePickerDialog(ListPillBoxActivity.this, startPillBoxDateListener,
year, monthOfYear, dayOfMonth);
每个参数都正确地传递到datePickerDialog,但是在弹出对话框中存在问题
every parameters is passed correctly to the datePickerDialog, but there is an issue in inflating dialog
感谢任何帮助....
推荐答案
我遇到了同样的问题.解决方案是在样式中添加三个项目,例如在DatePickerSamples中:
I ran into the same problem. The solution is to add three items to your style like in the 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>
这篇关于Simon Ics日期选择器对话框引发android.view.InflateException:二进制XML文件第20行:膨胀类net.simonvt.widget.DatePicker时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!