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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:22:45+00:00 2026-06-15T07:22:45+00:00

Here is what I would like my application to do on a tablet. Fragment

  • 0

Here is what I would like my application to do on a tablet.
Fragment (0) has some menu that would display fragments (1)…(n) like this:

-----------------
|   |   |   |   |
|   |   |   |   |
|(0)| X | X | X |
|   |   |   |   |
|   |   |   |   |
-----------------
 becomes
-----------------
|   |   |   |   |
|   |   |   |   |
|(0)|(1)| X | X |
|   |   |   |   |
|   |   |   |   |
-----------------
 and then
-----------------
|   |   |   |   |
|   |   |   |   |
|(0)|(2)|(1)| X |
|   |   |   |   |
|   |   |   |   |
-----------------
 etc... 

Fragment0 never moves, the other ones are shifted to the right. Fragments going off the edge to the right will be destroyed.

So I setup my XML layout with a horizontal LinearLayout and containing 4 FrameLayout with the proper IDs (fragment0… fragment3)

I can instantiate and display fragment0 and then fragment1, but I am not able to shift it to the right after, I get:

ERROR/AndroidRuntime(343): FATAL EXCEPTION: main
java.lang.IllegalStateException: Can't change container ID of fragment ...

The only related questions I have found are this one and that one, tried all the different solutions offered with no luck.

Tried FragmentTransaction.remove() followed by .add(), tried .replace(), tried them in different orders and to commit half-way through (even trying to commit twice as somebody suggested), tried to call addToBackStack() … still no luck.

Question is whether it is possible to move the fragments like this with a FragmentTransaction. If yes, what am I doing wrong (and bonus, is it possible to animate that?). If no, what would be the proper way to implement this?

Note that I don’t want to re-instantiate the fragments every time (each do some queries on the web that can take some time). It’s possible to extract all the data back to the activity to recreate one, but I’d rather not do that if possible…

  • 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-15T07:22:46+00:00Added an answer on June 15, 2026 at 7:22 am

    I don’t know if this is quite what you want but I made a little sample regarding your problem. Basically you’ll be doing the right shifting using the layout file, having a wrapper container for each of those shifting fragments. The code sample is a little to big for an answer so I’ve posted it into a gist that you can find here. In that sample press each of the ListFragment‘s items(Fragment 1 -> Fragment 2 -> fragment 3) to see the behavior.

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

Sidebar

Related Questions

I'm developing a web application that involves the use of timestamps. I would like
i would like to create an application in this context : Zk 6, Spring
Here is a screenshot of my tablet application (not using fragments for now): So
Here is the problem : I would like to create an application on an
$('#selector').click(function() { // here I would like to load a javascript file // let's
A bit of a complex problem to describe here: I would like to have
I'm following the documentation here as I would like to add Actors to the
I am using jquery uploader from here and I would like to know how
Here is what I would like to achieve: I have a web service A
Here's the situation: I would like to iterate through a table with input controls,

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.