2014-02-19 131 views
0

我有用於創建Tablayout的actionbarcompact庫。 但當我點擊標籤非常快,然後Illegalargumentexcpetion拋出Android碎片,illegalargumentexception

當我通過日誌,然後我觀察oncreate的片段之前調用其他片段的ondestroy。 由於每個標籤的容器標識不同。 Illegalargument異常:未發現爲id發現的視圖。

任何建議來解決這個問題。

stack trace 
02-19 14:20:11.601: D/FragmentManager(21544):  #16: MoreFragment{4203be70 #16 id=0x7f060176  tag_more_fragment} 
02-19 14:20:11.601: D/FragmentManager(21544):  mFragmentId=#7f060176 mContainerId=#7f060176 mTag=tag_more_fragment 
02-19 14:20:11.602: D/FragmentManager(21544):  mState=0 mIndex=16 mWho=android:fragment:16 abackStackNesting=0 
02-19 14:20:11.602: D/FragmentManager(21544):  mAdded=true mRemoving=false mResumed=false mFromLayout=false mInLayout=false 
02-19 14:20:11.602: D/FragmentManager(21544):  mHidden=false mDetached=false mMenuVisible=true mHasMenu=false 
02-19 14:20:11.602: D/FragmentManager(21544):  mRetainInstance=true mRetaining=false mUserVisibleHint=true 
02-19 14:20:11.603: D/FragmentManager(21544):  mFragmentManager=FragmentManager{41fb92f8 in MenuActivity{421ccb08}} 
02-19 14:20:11.603: D/FragmentManager(21544):  [email protected] 
02-19 14:20:11.603: D/FragmentManager(21544): Added Fragments: 
02-19 14:20:11.603: D/FragmentManager(21544):  #0: CustomProgressDialogFragment{42587140 #15 tag_custom_progress_dialog} 
02-19 14:20:11.603: D/FragmentManager(21544):  #1: DealerFragmentStack{42524e60 #2 id=0x1020011 DealerFragmentStack} 
02-19 14:20:11.604: D/FragmentManager(21544):  #2: MoreFragment{4203be70 #16 id=0x7f060176 tag_more_fragment} 
02-19 14:20:11.604: D/FragmentManager(21544): Fragments Created Menus: 
02-19 14:20:11.606: D/FragmentManager(21544):  #0: SellingDealerDetailsFragment{41f291e8 #14 id=0x7f0600d1 tag_selling_dealer_details_fragment} 
02-19 14:20:11.607: D/FragmentManager(21544): FragmentManager misc state: 
02-19 14:20:11.607: D/FragmentManager(21544):  [email protected] 
02-19 14:20:11.607: D/FragmentManager(21544):  m  [email protected] 
02-19 14:20:11.607: D/FragmentManager(21544):  mCurState=5 mStateSaved=false mDestroyed=false 
02-19 14:20:11.608: D/FragmentManager(21544): View Hierarchy: 
02-19 14:20:11.608: D/FragmentManager(21544):  com.android.internal.policy.impl.PhoneWindow$DecorView{42562fc0 V.E..... ... 0,0-720,1184} 
02-19 14:20:11.608: D/FragmentManager(21544):  com.android.internal.widget.ActionBarOverlayLayout{4247d508 V.E..... ... 0,0-720,1184 #1020312 android:id/action_bar_overlay_layout} 
02-19 14:20:11.609: D/FragmentManager(21544):   android.widget.FrameLayout{425a3228 V.E..... ... 0,242-720,1184 #1020002 android:id/content} 
02-19 14:20:11.609: D/FragmentManager(21544):   android.widget.FrameLayout{42554ed0 V.E..... ... 0,0-720,942 #1020011 android:id/tabcontent} 
02-19 14:20:11.609: D/FragmentManager(21544):    android.support.v4.app.NoSaveStateFrameLayout{4228ba28 V.E..... ... 0,0-0,0} 
02-19 14:20:11.609: D/FragmentManager(21544):    android.widget.LinearLayout{420a1420 V.E..... ... 0,0-0,0} 
02-19 14:20:11.610: D/FragmentManager(21544):     android.widget.FrameLayout{4219faa8 V.E..... ... 0,0-0,0 #7f0600d1 app:id/dealer_fragment} 
02-19 14:20:11.611: D/FragmentManager(21544):   com.android.internal.widget.ActionBarContainer{422b7ab8 V.ED.... ... 0,50-720,242 #1020313 android:id/action_bar_container} 
02-19 14:20:11.611: D/FragmentManager(21544):   com.android.internal.widget.ActionBarView{422a1460 V.E..... ... 0,0-720,96 #1020314 android:id/action_bar} 
02-19 14:20:11.612: D/FragmentManager(21544):    android.widget.LinearLayout{4255c168 VFE...C. ... 17,0-427,96} 
02-19 14:20:11.612: D/FragmentManager(21544):    com.android.internal.widget.ActionBarView$HomeView{42575840 V.E..... ... 0,0-80,96} 
02-19 14:20:11.612: D/FragmentManager(21544):     android.widget.ImageView{42523de8 G.ED.... ... 0,0-0,0 #102025c android:id/up} 
02-19 14:20:11.613: D/FragmentManager(21544):     android.widget.ImageView{425a20f0 V.ED.... ... 8,16-72,80 #102002c android:id/home} 
02-19 14:20:11.613: D/FragmentManager(21544):    android.widget.LinearLayout{4256f900 V.E..... ... 80,24-410,72} 
02-19 14:20:11.614: D/FragmentManager(21544):     android.widget.TextView{42504950 V.ED.... ... 0,0-314,48 #1020266 android:id/action_bar_title} 
02-19 14:20:11.614: D/FragmentManager(21544):     android.widget.TextView{42502520 G.ED.... ... 0,0-0,0 #1020267 android:id/action_bar_subtitle} 
02-19 14:20:11.614: D/FragmentManager(21544):    com.android.internal.view.menu.ActionMenuView{420f7318 V.ED.... ... 608,0-720,96} 
02-19 14:20:11.615: D/FragmentManager(21544):    com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton{42596b70 VFED..C. ... 0,0-112,96} 
02-19 14:20:11.615: D/FragmentManager(21544):   com.android.internal.widget.ActionBarContextView{4244f028 G.E..... ... 0,0-0,0 #1020315 android:id/action_context_bar} 
02-19 14:20:11.616: D/FragmentManager(21544):   com.android.internal.widget.ScrollingTabContainerView{424bf0d8 VFED.... ... 0,96-720,192} 
02-19 14:20:11.616: D/FragmentManager(21544):    android.widget.LinearLayout{4255ea28 V.ED.... ... 0,0-968,96} 
02-19 14:20:11.616: D/FragmentManager(21544):    com.android.internal.widget.ScrollingTabContainerView$TabView{425928b0 VFE...C. ... 0,0-242,96} 
02-19 14:20:11.617: D/FragmentManager(21544):     android.widget.ImageView{42476988 V.ED.... ... 58,20-114,76} 
02-19 14:20:11.617: D/FragmentManager(21544):     android.widget.TextView{42559860 V.ED.... ... 114,31-183,64} 
02-19 14:20:11.617: D/FragmentManager(21544):    com.android.internal.widget.ScrollingTabContainerView$TabView{425a4c00 VFE...C. ... 244,0-486,96} 
02-19 14:20:11.618: D/FragmentManager(21544):     android.widget.ImageView{424b2b78 V.ED.... ... 32,20-88,76} 
02-19 14:20:11.618: D/FragmentManager(21544):     android.widget.TextView{42561780 V.ED.... ... 88,31-210,64} 
02-19 14:20:11.618: D/FragmentManager(21544):    com.android.internal.widget.ScrollingTabContainerView$TabView{425b9348 VFE...C. .S. 488,0-730,96} 
02-19 14:20:11.618: D/FragmentManager(21544):     android.widget.ImageView{424caa00 V.ED.... .S. 49,20-105,76} 
02-19 14:20:11.619: D/FragmentManager(21544):     android.widget.TextView{42568058 V.ED.... .S. 105,31-193,64} 
02-19 14:20:11.619: D/FragmentManager(21544):    com.android.internal.widget.ScrollingTabContainerView$TabView{425c22d8 VFE...C. ... 732,0-974,96} 
02-19 14:20:11.619: D/FragmentManager(21544):     android.widget.ImageView{4256c9b8 V.ED.... ... 59,20-115,76} 
02-19 14:20:11.620: D/FragmentManager(21544):     android.widget.TextView{424d8100 V.ED.... ... 115,31-183,64} 
02-19 14:20:11.620: D/FragmentManager(21544):   com.android.internal.widget.ActionBarContainer{424b8478 G.ED.... ... 0,0-0,0 #1020316 android:id/split_action_bar} 


02-19 14:20:11.623: D/AndroidRuntime(21544): Shutting down VM 
02-19 14:20:11.623: W/dalvikvm(21544): threadid=1: thread exiting with uncaught exception (group=0x41674d28) 
02-19 14:20:11.626: E/AndroidRuntime(21544): FATAL EXCEPTION: main 
02-19 14:20:11.626: E/AndroidRuntime(21544): Process: com.scgp.ab, PID: 21544 
02-19 14:20:11.626: E/AndroidRuntime(21544): java.lang.IllegalArgumentException: No view found for id 0x7f060176 (com.scgp.ab:id/more_fragment) for fragment MoreFragment{4203be70 #16 id=0x7f060176 tag_more_fragment} 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.os.Handler.handleCallback(Handler.java:733) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.os.Handler.dispatchMessage(Handler.java:95) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.os.Looper.loop(Looper.java:137) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at android.app.ActivityThread.main(ActivityThread.java:5083) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at java.lang.reflect.Method.invokeNative(Native Method) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at java.lang.reflect.Method.invoke(Method.java:515) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 
02-19 14:20:11.626: E/AndroidRuntime(21544): at dalvik.system.NativeStart.main(Native Method) 
+1

請張貼堆棧跟蹤... – Emmanuel

+0

堆棧跟蹤太大,只公佈了一部分 – gulla

回答

0

你說,集裝箱ID對每個選項卡爲什麼如此不同。它應該是一個框架佈局,容器,並在選項卡選擇你應該用相同的容器替換你的碎片。

此外,錯誤說,

java.lang.IllegalArgumentException: No view found for id 0x7f060176 

這意味着視圖缺少你MoreFragment。初始化並確保以上,它應該工作。

舉一個例子,看here.

+0

應用程序有要求,即當點擊後退按鈕時,在該選項卡中,我們必須展示歷史記錄與該選項卡本身相關,當它到達該選項卡中的根片段時,應用程序必須註銷。只有當我用兩根手指快速更改標籤時,纔會發生此異常。 – gulla