0
我是新來的android和具有容器視圖(framelayout)的片段。它上面有兩個TextView,比如標籤。每個TextView即txt1,txt2
分別添加2個片段,即frgmnt1,frgmnt2
。當單擊TextView時,會添加相應的片段。如果再次點擊,片段被刪除。應用程序崩潰時,在不同的TextViews非常快速點擊
這部分工作正常。但是,當我非常快速地點擊TextView時,我的應用程序崩潰並顯示「無主機」異常。任何人都可以幫我理解爲什麼發生這種情況?
(注意,此處不需要製表符的佈局實現)。
這裏是堆棧跟蹤:
07-04 18:22:25.600 10971-10971/integral.com.sellfie E/AndroidRuntime: FATAL EXCEPTION: main
Process: integral.com.sellfie, PID: 10971
java.lang.IllegalStateException: No host
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1239)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1234)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2046)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1989)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at integral.com.sellfie.Fragments.MemberFragment.addFragment(MemberFragment.java:319)
at integral.com.sellfie.Fragments.MemberFragment.showFragment(MemberFragment.java:270)
at integral.com.sellfie.Fragments.MemberFragment$3.onClick(MemberFragment.java:242)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21168)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
把你的代碼在這裏 –
它可能是因爲你正試圖刪除添加甚至在它的片段。嘗試在確定點擊事件後停用視圖很短的時間(例如300毫秒)。 –
感謝Arpit Ratan,Vishal Patoliya的迴應和sairam的正確編輯。即,我需要禁用所有按鈕300ms.ok.i將檢查,並會回覆給你。 –