ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
Apache License 2.0
7.09k stars 1.34k forks source link

java.lang.IllegalStateException: Fragment already added #20

Closed siddharth96 closed 9 years ago

siddharth96 commented 9 years ago

Hi,

I got this error when I tapped the 5th tab as soon as the UI rendered:

E/AndroidRuntime(28502): java.lang.IllegalStateException: Fragment already added: GenericProductListFragment{3147a7ad #2 id=0x7f0d026f}
E/AndroidRuntime(28502):    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1209)
E/AndroidRuntime(28502):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:674)
E/AndroidRuntime(28502):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
E/AndroidRuntime(28502):    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
E/AndroidRuntime(28502):    at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
E/AndroidRuntime(28502):    at android.support.v4.view.ViewPager.populate(ViewPager.java:1072)
E/AndroidRuntime(28502):    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:554)
E/AndroidRuntime(28502):    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:513)
E/AndroidRuntime(28502):    at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:494)
E/AndroidRuntime(28502):    at com.ogaclejapan.smarttablayout.SmartTabLayout$TabClickListener.onClick(SmartTabLayout.java:474)
E/AndroidRuntime(28502):    at android.view.View.performClick(View.java:4780)
E/AndroidRuntime(28502):    at android.view.View$PerformClick.run(View.java:19866)
E/AndroidRuntime(28502):    at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(28502):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(28502):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(28502):    at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime(28502):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28502):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(28502):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
E/AndroidRuntime(28502):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Thanks, Siddharth

ogaclejapan commented 9 years ago

Hi, @siddharth96

That you can not understand that you are using how this library from the error log, Can you show me all of the parts of the code that sets up the FragmentManager?

siddharth96 commented 9 years ago

Hi,

I don't think it's something wrong with your library. I'd overrident the getItem() implementation while extending PagerAdapter, and my implementation was causing this. Fixed my code, and this issue also went away. I'll close this issue.

Thanks for this awesome library. Cheers!

ogaclejapan commented 9 years ago

:+1:

AhmadullahSaikat commented 5 years ago

👍 91

nehagarg702 commented 4 years ago

can ypu tell. How you fixed this issue?