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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:31:55+00:00 2026-05-30T16:31:55+00:00

I’m working on an android app which has different layouts for phone vs tablet.

  • 0

I’m working on an android app which has different layouts for phone vs tablet. On the phone, my game activity layout works as a tabbed UI with 4 tabs, we’ll call them A, B, C, and D. I have a tabbar of buttons and a ViewFlipper with 4 fragments in it. So when they tap the C tab, the ViewFlipper shows that child which is FragmentC. FragmentC contains a ListView. When a user taps an item then I want to show a detail view about that item. So, FragmentC adds a new DetailFragment with a FragmentTransaction. This new DetailFragment covers FragmentC entirely. I’m basically trying to get a UINavigationController type of behavior if you are familiar with iOS. This works just fine on the phone.

On the tablet my game activity layout just splits the screen into 4 equal quadrants with FragmentA, FragmentB, FragmentC and FragmentD. That appears to work just fine, they all display just fine. However, when on the tablet UI, if I tap one of the items in the ListView in FragmentC the code is executed to add the new fragment, but nothing shows up on the screen.

My phone gameactivity.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/viewRoot" ...>
    <LinearLayout android:id="@+id/tabBarRoot" ...>
        <Button ... />
        <Button ... />
        <Button ... />
        <Button ... />
    </LinearLayout>

    <ViewFlipper android:id="@+id/viewFlipperMainMenu" ...>
        <fragment class="FragmentA" ... />
        <fragment class="FragmentB" ... />
        <fragment class="FragmentC" ... />
        <fragment class="FragmentD" ... />
    </ViewFlipper>
</RelativeLayout>

My tablet gameactivity.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/viewRoot" ... >
    <LinearLayout ... >
        <fragment class="FragmentB" ... />
        <fragment class="FragmentA" ... />
    </LinearLayout>

    <LinearLayout ... >
        <fragment class="FragmentC" ... />
        <fragment class="FragmentD" ... />
    </LinearLayout>

</LinearLayout>

FragmentC’s layout xml for both phone and tablet:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/viewRoot" ... >

    <ListView android:id="@+id/listView" ... />

</LinearLayout>

When a List item in FragmentC is tapped, FragmentC will add a new DetailFragment with the following code:

public void pushNewFragment(Fragment fragment, String description) {
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();

    transaction.add(R.id.viewRoot, fragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                    .addToBackStack(description).commit();
}

On the phone, this works just fine and DetailFragment shows up. On the tablet, nothing visibly happens when the pushNewFragment() method is called.

Any ideas?

  • 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-05-30T16:31:57+00:00Added an answer on May 30, 2026 at 4:31 pm

    Could it be that you have two LinearLayouts with an id of @+id/viewRoot in your hierarchy (one in gameactivity.xml, one in Fragment C’s xml)?

    I’m thinking it might be attempting to attach the Fragment at the wrong point in the hierarchy for some reason, though I couldn’t say why this would only be a problem for one screen layout.

    Edit:

    It might be that your tablet’s gameactivity.xml simply contains no more room for further child views. i.e. You have a top level LinearLayout containing two child LinearLayouts. I’m guessing those child LinearLayouts have been configured with layout_height and layout_width to ensure they fill the parent. If you then add another view to the parent LinearLayout, it probably will have no remaining space in which to render.

    What if you wrap the parent LinearLayout in a FrameLayout and give that the id of @+id/viewRoot s that the new fragment can overlay the existing fragments?

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
We're building an app, our first using Rails 3, and we're having to build

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.