启动片段时出现空指针异常

时间:2013-05-05 19:15:02

标签: android android-fragments

我在平板电脑上启动应用时遇到此异常。它在手机上运行得非常好。

> 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。我的第一个标题没有片段,因此,安装可能失败了。有办法解决这个问题吗?

谢谢!

0 个答案:

没有答案