JakeWharton/ActionBarSherlock — Issue #105: InflateException when starting SherlockPreferenceActivity in landscape
Author: nelenkov
Created: 2011-11-07 02:55:39+00:00
State: open

This is caused by the in layout-land/abs__screen_action_bar.xml and this inflate call in SherlockPreferenceActivity:

View view = getLayoutInflater().inflate(R.layout.abs__screen_action_bar, null);

The root parameter is obviously null, but not sure how to work around this.

Reproduced on Android 2.1-2.3.

Stacktrace:

```java
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nick.wwwjdic/org.nick.wwwjdic.WwwjdicPreferences}: android.view.InflateException: can be used only with a valid ViewGroup root and attachToRoot=true
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: can be used only with a valid ViewGroup root and attachToRoot=true
at android.view.LayoutInflater.inflate(LayoutInflater.java:379)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at android.support.v4.app.SherlockPreferenceActivity.ensureSupportActionBarAttached(SherlockPreferenceActivity.java:155)
at android.support.v4.app.SherlockPreferenceActivity.onCreate(SherlockPreferenceActivity.java:262)
at org.nick.wwwjdic.WwwjdicPreferences.onCreate(WwwjdicPreferences.java:110)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
... 11 more
android.view.InflateException: can be used only with a valid ViewGroup root and attachToRoot=true
at android.view.LayoutInflater.inflate(LayoutInflater.java:379)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at android.support.v4.app.SherlockPreferenceActivity.ensureSupportActionBarAttached(SherlockPreferenceActivity.java:155)
at android.support.v4.app.SherlockPreferenceActivity.onCreate(SherlockPreferenceActivity.java:262)
at org.nick.wwwjdic.WwwjdicPreferences.onCreate(WwwjdicPreferences.java:110)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
at android.app.ActivityThread.access$1500(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4196)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
```