Spinner - throwing an exception when using AppCompat

I have implemented an Android application for reading books. My application has two modes - day and night.

For day mode, I use a theme whose parent set is equal @style/Theme.AppCompat.Light.NoActionBar. For night mode, the parent element @style/Theme.AppCompat.NoActionBar.

In the first mode (day), everything works fine. But there is a problem when the user changes the mode at night. I have a problem with Spinnerwhich fits in my snippet. Immediately after changing the mode for the night, I see the following exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{cz.company.media/cz.comapy.reader.activity.reader.ReadingActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5111)
     at android.app.ActivityThread.access$1100(ActivityThread.java:198)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1682)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:145)
     at android.app.ActivityThread.main(ActivityThread.java:6837)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
  Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
     at android.view.LayoutInflater.createView(LayoutInflater.java:640)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:366)

I found out that in my layout on line 19 is Spinner. I am targeting SDK version 22. All my actions extend from AppCompatActivity, and all my dialogs extend from AppCompatDialogFragment. I also tried changing Spinnerto AppCompatSpinner, but that does not affect.

, Samsung Galaxy S6 Android 5.1.1.

, Nexus 5, Samsung Galaxy S4, Motorola Xoom, Xperia Z2, .

- , ?

UPDATE

19 xml :

<android.support.v7.widget.AppCompatSpinner [this is line 19]
        android:id="@+id/spinner_display_settings_motif"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:entries="@array/display_setting_motif_types"/>

Spinner, .

+4
1

, /:

<item name="android:src">something</item>

.

+1

Source: https://habr.com/ru/post/1620560/


All Articles