Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:45:35+00:00 2026-06-12T10:45:35+00:00

this question had been asked here numerous times, however I couldn’t find help in

  • 0

this question had been asked here numerous times, however I couldn’t find help in any of them. I’m writing an android application and seem to have a problem with creating tabs on the ActionBar. I’ve been looking for the problem for a couple of hours and can’t seem to find the solution, however I think I did find the source. I’ve even emptied the implementations just to get some results and build upon them but alas I didn’t find anything.

this is the creating of the tab fragment and insertion to the actionbar

    // put ActionBar to nav. mode
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // init "YES" tab
    Fragment yesTabFragment = Fragment.instantiate(this, YesTabFragment.class.getName());
    FlowTabListener yesTabListener = new FlowTabListener(yesTabFragment);
    ActionBar.Tab yesTab = actionBar.newTab().setText("YES").setTabListener(yesTabListener);
    actionBar.addTab(yesTab);

this is the onCreateView method of the class

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    _fragmentView =  inflater.inflate(R.layout.yes_fragment, container);    
}

and this is the fragment XML layout

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" >

    </LinearLayout>

as you can see, the implementations are empty, and i do not instantiate this fragment before this time (and not after) however I get this error:

E/AndroidRuntime(2995): FATAL EXCEPTION: main
E/AndroidRuntime(2995): java.lang.RuntimeException: Unable to start activity ComponentInfo{activities.MainActivity}:    
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

I think it has something to do with the addition of the tab to the action bar since when I comment out the actionBar.addTab() the application does run (without the tabs obviously)

I would really like for a hint on how to sort this out.

Thanks a head guys

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:45:36+00:00Added an answer on June 12, 2026 at 10:45 am

    The second parameter of inflate() is the default parent:

    _fragmentView =  inflater.inflate(R.layout.yes_fragment, container);
    

    Change this line to:

    _fragmentView =  inflater.inflate(R.layout.yes_fragment, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question had been asked a hundred times, but I have difficulties
I know that this question had already been asked a couple of times before,
This question has been asked and answered numerous times, but I'm still stumped. All
I know that this question had been asked many times, but every answer seems
I know this question has been asked several times, however, after digging through question
I know this question has been asked multiple times (however, I could still not
This question may have been asked before, but I had trouble finding an answer,
Various incarnations of this question have been asked here before, but I thought I'd
I imagine this question has been asked and answered, but I cannot find it.
I know this question has been asked before, but I've had little success even

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.