Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

  • swipey_tabs_stretched.xml
  • IconSwipeyTabsView.java

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

like image 413
user2062024 Avatar asked Jul 12 '13 14:07

user2062024


1 Answers

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

like image 157
Yjay Avatar answered Oct 05 '22 02:10

Yjay