NullPointerException异常上Backstack [英] NullpointerException on Backstack
问题描述
我使用的API级别16,在我试图取代下面的一些标签一些碎片已经在那里
一些片段。我真的不能找到一个原因,但有时我得到这样一个例外:
I use API Level 16, in i try to replace some Fragment below some Tab where already is some Fragment. I cant really find a reason why, but sometimes i get an Exception like this:
E/AndroidRuntime(27395): java.lang.NullPointerException
E/AndroidRuntime(27395): at android.app.BackStackRecord.run(BackStackRecord.java:604)
E/AndroidRuntime(27395): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399)
E/AndroidRuntime(27395): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
E/AndroidRuntime(27395): at android.os.Handler.handleCallback(Handler.java:615)
E/AndroidRuntime(27395): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(27395): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(27395): at android.app.ActivityThread.main(ActivityThread.java:4921)
E/AndroidRuntime(27395): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(27395): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(27395): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
E/AndroidRuntime(27395): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
E/AndroidRuntime(27395): at dalvik.system.NativeStart.main(Native Method)
我不添加一个空片段和code运行有简单的:
I do not add an null Fragment and code running there is simple:
final Fragment newFragment = Fragment.instantiate(anContext, clazz.getName(), arguments);
final FragmentTransaction transaction = manager.beginTransaction();
transaction.disallowAddToBackStack();
transaction.replace(R.id.fragment_content_center, newFragment);
transaction.commit();
如果你喜欢,有grep的code一看,因为有异常情况发生:<一href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.1.2_r1/android/app/BackStackRecord.java#604\" rel=\"nofollow\">http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/4.1.2_r1/android/app/BackStackRecord.java#604
If you like, have a look on Grepcode, as there the Exception happens: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/app/BackStackRecord.java#604
林不使用任何动画那里。
Im not using any Animations there.
推荐答案
的问题是不同的东西,
我是使用在每个事务中的片段标记做更换呼叫时。
在上部code 我没有。造成这个NullPointerException异常。
i was using in each Transaction an Fragment TAG when doing the replace call. On the upper code i didnt. That was causing this NullPointerException.
看起来像你不能组合的交易,文档是不明确有关。
Look like you cant mix transactions, Documentation is not clear about that.
感谢名单,
Kitesurfer
thanx, Kitesurfer
这篇关于NullPointerException异常上Backstack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!