其他分享
首页 > 其他分享> > Simon Ics Date Picker Dialog抛出android.view.InflateException:二进制XML文件行#20:错误膨胀类net.simonvt.widget.Dat

Simon Ics Date Picker Dialog抛出android.view.InflateException:二进制XML文件行#20:错误膨胀类net.simonvt.widget.Dat

作者:互联网

我在我的Android应用程序中使用了Simon的ICS日期选择器库(https://github.com/SimonVT).
我有一个日期按钮,如果我点击该按钮,它将在对话框中显示ics datepicker.
我的问题是,如果我点击按钮,它不显示datepicker对话框,但它显示以下错误:

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指向以下行:

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

每个参数都正确传递给datePickerDialog,但在膨胀对话框中存在问题

任何帮助赞赏….

解决方法:

我遇到了同样的问题.解决方案是在您的样式中添加三个项目,如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>

标签:android,android-datepicker,android-simon-datepicker
来源: https://codeday.me/bug/20190529/1179383.html