当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Null Pointer Exception occurs while starting fragment

问题描述:

I am facing this exception while starting the app on tablet. It works perfectly fine on phone.

> 05-06 00:34:48.213: E/AndroidRuntime(545): Caused by:

> java.lang.NullPointerException: name == null 05-06 00:34:48.213:

> E/AndroidRuntime(545): at

> java.lang.VMClassLoader.findLoadedClass(Native Method) 05-06

> 00:34:48.213: E/AndroidRuntime(545): at

> java.lang.ClassLoader.findLoadedClass(ClassLoader.java:354) 05-06

> 00:34:48.213: E/AndroidRuntime(545): at

> java.lang.ClassLoader.loadClass(ClassLoader.java:491) 05-06

> 00:34:48.213: E/AndroidRuntime(545): at

> java.lang.ClassLoader.loadClass(ClassLoader.java:461) 05-06

> 00:34:48.213: E/AndroidRuntime(545): at

> android.app.Fragment.instantiate(Fragment.java:562) 05-06

> 00:34:48.213: E/AndroidRuntime(545): at

> android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1117)

> 05-06 00:34:48.213: E/AndroidRuntime(545): at

> android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1150)

> 05-06 00:34:48.213: E/AndroidRuntime(545): at

> android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:551)

It looks like if the headers don't have a fragment defined, it fails on tablet as it tries to focus on the first header by default. My first header is not having a fragment, hence, the installation is failing probably. Is there a way to get around this ?

Thanks!

分享给朋友:
您可能感兴趣的文章:
随机阅读: