I am using TabLayout
from the design library with the ViewPager
, linking them using the function setupWithViewPager
. The app is crashing in scenarios where it recreates the tabs, after the tab contents have been changed. Crash trace :
java.lang.IllegalArgumentException: Tab belongs to a different TabLayout.
at android.support.design.widget.TabLayout.addTab(TabLayout.java:433)
at android.support.design.widget.TabLayout.populateFromPagerAdapter(TabLayout.java:772)
at android.support.design.widget.TabLayout.setPagerAdapter(TabLayout.java:763)
at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:715)
The crash is occuring after updating to support library 23.2.0, doesn't reproduce till v23.1.1.
TabLayout is used to implement horizontal tabs. TabLayout is released by Android after the deprecation of ActionBar. TabListener (API level 21). TabLayout is introduced in design support library to implement tabs. Tabs are created using newTab() method of TabLayout class.
You create tabs via newTab() . From there you can change the tab's label or icon via TabLayout. Tab. setText(int) and TabLayout.
TabLayout is introduced in the design support library to implement tabs. Tabs are created using the newTab() method of TabLayout class. The title and icon of Tabs are set through setText(int) and setIcon(int) methods of TabListener interface respectively.
Just found that this is an internal bug in Support library v23.2.0, registered at : https://code.google.com/p/android/issues/detail?id=201827
This was bug reported on google https://code.google.com/p/android/issues/detail?id=201827
But after release of Android Support Library, revision 23.2.1 (March 2016) This is fixed now.
just update Support Library to Android Support Library to 23.2.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With