I have implemented Android application for reading books. My application has two modes - day and night.
For day mode I am using theme, which has the parent set to @style/Theme.AppCompat.Light.NoActionBar
. For the night mode the parent is @style/Theme.AppCompat.NoActionBar
.
In the first mode (day) everything works fine. But there is a problem when user change mode to night. I have a problem with Spinner
, which is placed in my fragment. Immediately after changing mode to 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 there is a Spinner
in my layout on line 19. I am targeting SDK version 22. All of my activities extend from AppCompatActivity
and all of my dialogs extend from AppCompatDialogFragment
. I also tried to change Spinner
to AppCompatSpinner
, but it has no effect.
And it is very weird, that this happened to me only on device Samsung Galaxy S6 with Android 5.1.1.
I tested it on some other devices, like Nexus 5, Samsung Galaxy S4, Motorola Xoom, Xperia Z2 tablet and it works absolutely fine.
Does anybody have an idea, what could be wrong?
UPDATE
On line 19 in my xml
file is following:
<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"/>
I also tried to use classic Spinner
, but it is same.