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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:13:30+00:00 2026-06-14T17:13:30+00:00

I have a framelayout (A) as a base view in my baseActivity, I then

  • 0

I have a framelayout (A) as a base view in my baseActivity, I then add an additional view (B), which may include a SearchFragment. I want to remove the SearchFragment from this layout B and add it to the outer layout A.

 private void reparentSearchFragment(ViewGroup view, FrameLayout container){
    View search = view.findViewById(R.id.search_fragment);
        if(search != null && view instanceof ViewGroup){
            view.removeView(search);
            container.addView(search);
    } 
}

This seems to be failing, logs are Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

I find this odd, as I am removing the view, as you can see in the code snippet. Any ideas? Thanks 🙂

  • 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-14T17:13:31+00:00Added an answer on June 14, 2026 at 5:13 pm

    Add fragment to B layout dinamically from code.

    And when you need to put it in A, you will have to remove fragment and add it again like this:

    SearchFragment s = ...;
    FragmentTransaction t = getSupportFragmentManager().beginTransaction();
    t.remove(s);
    t.add(R.layout.A_ID, s);
    t.commit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a FrameLayout (within a RelativeLayout ) to/from which I add/remove Fragments by
I have a FrameLayout view which contains one (MapView-like) control and some additional buttons
I have a FrameLayout in which I have placed two identical TextViews. I want
I have a FrameLayout in which I have 2 controls: - a custom view
I have a group of FrameLayout which I want to be checkable/selectable, That is,
I have a custom FrameLayout class which does some custom drawing on the OnSizeChanged
Ho I have two list view on a frame layout. I want one overlay
I want to have a view with several choices when I click an element
am creating an application in which i am using framelayout ..... I have used
Say I have a framelayout as the view of a appwidget. The framelayout have

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.