2013-09-25 144 views
1

我创建了一个包含Activity的TabActivity类。当屏幕锁定在片段中时应用程序崩溃

我已经crated Fragments并在活动中使用该Fragment。

在屏幕锁定之前,一切正在完善。

当屏幕被锁定时,应用程序崩溃。

这是堆栈跟踪

09-25 15:54:36.306: 
E/AndroidRuntime(21443): java.lang.IllegalArgumentException: 
No view found for id 0x7f09003d (...id/linearLayoutSC) for fragment SubCategoryGrid{42bbaf70 #7 id=0x7f09003d subCatList} 

请帮我解决这个问题。

我试图打印在日志中的onDestroy()onDetach()方法。它被调用TabActivity中的所有片段。

我试过这个链接,但没有运气。

https://stackoverflow.com/a/9446326/1395259

IllegalArgumentException: No view found for id for fragment when fast switching ActionBar Tabs

这是错误?

https://code.google.com/p/android/issues/detail?id=19211

+0

这可能帮助:: HTTP://stackoverflow.com/questions/12057409/app-crashes-when-started-again-for-我第二次使用 – ASP

+1

我正在使用Fragment队友。在1个活动中,我有多个片段。如果屏幕被锁定,则对tabActivity中的所有碎片调用onDetach()和onDestroy()。这就是为什么布局文件也错过了。我想保存它。这不是我查询的解决方案。 –

回答

5

问题已解决。

我不知道这里的作用是什么,但它解决了我的问题,并且完美地工作。

android:configChanges="orientation|keyboardHidden|screenSize" 

我已经写在menifest文件上面的行内activity

现在,它的工作完美。下面的代码:

0

我通过添加清单解决问题

<activity 
      android:name="com.android.Take Activity" 
      android:exported="true" 
      android:configChanges="orientation|screenSize" 
      android:noHistory="true" 
      android:screenOrientation="landscape" 
      android:windowSoftInputMode="stateHidden" > </activity> 
相关问题