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 8966089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:57:02+00:00 2026-06-15T16:57:02+00:00

My app is simple. I have a main activity with a sort of dock

  • 0

My app is simple. I have a main activity with a sort of dock at the bottom, with 4 icons: A, B, C, D.

When the apps starts, the icon A is active, and its contents is displayed on the screen. The contents of A is a ViewPager containing 3 screens that you can change by swiping horizontally.

So my main Activity is a FragmentActivity, which has a “content” framelayout, and a “dock” fragment. The framelayout is hence inflated with a viewpager.

Problem is, my ViewPager contains 3 Fragments. Hence, these 3 Fragments are nested into the content Fragment. If I try to replace the content Fragment (ie the ViewPager) with another Fragment (say the user clicked on icon B in the dock), it crashes because Android doesn’t support nested Fragments.

I tried to change the main activity to a TabActivity, so that the 3 Fragments will be nested into an activity instead of a Fragment. That’s great it works.

Except that TabActivity is deprecated, and I am advised to use… Fragments!

What could be done here?

Edit: let me paste the stack trace

01-26 00:03:41.167 E/AndroidRuntime(32723): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.view.ViewGroup.addViewInner(ViewGroup.java:3344)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.view.ViewGroup.addView(ViewGroup.java:3215)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.view.ViewGroup.addView(ViewGroup.java:3172)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.view.ViewGroup.addView(ViewGroup.java:3152)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.NoSaveStateFrameLayout.wrap(NoSaveStateFrameLayout.java:40)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:874)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.os.Handler.handleCallback(Handler.java:605)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.os.Looper.loop(Looper.java:137)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at android.app.ActivityThread.main(ActivityThread.java:4340)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at java.lang.reflect.Method.invokeNative(Native Method)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at java.lang.reflect.Method.invoke(Method.java:511)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-26 00:03:41.167 E/AndroidRuntime(32723):     at dalvik.system.NativeStart.main(Native Method)

Edit2: more code

In the xml I have a FrameLayout

In my main activity onCreate:

    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.add(R.id.main_contents, new HomeFragment());
    ft.commit();

So the ViewPager is not implemented in the XML, but is programmatically added into a FrameLayout.

The crash happens when I’m trying to create a new transaction that .replace()s the R.id.main_contents with a new SurvivalFragment()

  • 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-15T16:57:04+00:00Added an answer on June 15, 2026 at 4:57 pm

    Good news, nesting fragments is now supported in Jelly Bean and newest Support Package

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my android app, I have two activities mainactivity and erroractivity main activity starts
I have a simple android app to play videos. I have a main screen
I'm trying to write my first simple mvc app. I have a Main View
I have following simple method in my main activity. private void showMap(String name )
Ok I have a simple main activity that just presents the user with a
I have a simple problem. In my app I have 3 activities A,B,C. Activity
I have an android app that starts with a simple screen and a start
This is a real newbie question. I have simple app that selects a picture
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*
I have a simple app where you can login it looks like this: {{#view

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.