Android - FragmentTabHost gives me "No tab known for tag null"
Asked Answered
P

1

7

I have an activity that uses a TabHost associated with ViewPager. Although it works fine, I decided to replace it with FragmentTabHost. However, after making some changes, I am getting a rendering exception whose messages is as follows.

W/System.err(21723): java.lang.IllegalStateException: No tab known for tag null
W/System.err (21723):   at android.support.v4.app.FragmentTabHost.doTabChanged(FragmentTabHost.java:326)
W/System.err(21723):    at android.support.v4.app.FragmentTabHost.onAttachedToWindow(FragmentTabHost.java:276)
W/System.err(21723):    at android.view.View.dispatchAttachedToWindow(View.java:12064)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2707)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2714)
W/System.err(21723):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1339)
W/System.err(21723):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1131)
W/System.err(21723):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4611)
W/System.err(21723):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
W/System.err(21723):    at android.view.Choreographer.doCallbacks(Choreographer.java:555)

Basically what I did was to make a class named IconSwipeyTabsView which extends FragmentTabHost and use in a main activity or fragment. I did a lot of research on Google and StackOverflow but none of them gave me a clear answer. FYI, these are the urls of the two core files.

If anyone can help me out, I'd really appreciate it. Thanks!

Papery answered 12/7, 2013 at 14:48 Comment(2)
If you see IconSwipeyTabsView.java, I didn't set it to null. See how I initialized tabHost... final FragmentTabHost.TabSpec tabSpec = newTabSpec("").setIndicator(view).setContent(..);Papery
I didn't get this error when I was using TabHost..:(Papery
B
1

Are you calling IconSwipeyTabsView.setup(FragmentManager fm) in your activity?

The No tab known for tag null error can occur if the setup method in FragmentTabHost is not called. In case searching for this error leads others here, make sure to call one of the following after creating your FragmentTabHost object:

FragmentTabHost.setup(Context context, FragmentManager manager)

FragmentTabHost.setup(Context context, FragmentManager manager, int containerId)

Details: FragmentTabHost

Bully answered 6/1, 2014 at 22:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.