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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:56:39+00:00 2026-06-16T04:56:39+00:00

I have an app that has a screen like this (on a 10" tablet)

  • 0

I have an app that has a screen like this (on a 10" tablet) :

enter image description here

Now I need to amend the app to also work on a phone. As the screens will be smaller, I want to take the "split view" UI and change it so that the left hand side list view is shown on its own, then on selecting a row the appropriate right hand side list view is then shown.

How do I handle this in the app, as one activity currently handles both listviews, and I guess the phone will need two one for each listview.

How do I detect which one to do?

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-16T04:56:41+00:00Added an answer on June 16, 2026 at 4:56 am

    See Supporting Different Screen Sizes.

    Typically this is done using Fragments, but the basic idea is the same whether you use fragments or not. You create two different layouts for your Activity depending on the screen size.

    • Save the default layout single-pane for phones at res/layout/activity_main.xml
    • Save the dual-pane tablet layout at res/layout/activity_main_twopane.xml

    Then you use layout alias files with the screen size qualifiers described in the link to determine when the tablet layout should be used. For example to show the dual-pane layout on large screens and on screens with at least 600dp in the widest direction (includes large screen phones such as the Galaxy S3), you could do this:

    • res/values-large/layout.xml contains:

      <resources>
          <item name="activity_main" type="layout">@layout/activity_main_twopane</item>
          <bool name="twopane">true</bool>
      </resources>
      
    • res/values-sw600dp/layout.xml contains:

      <resources>
          <item name="activity_main" type="layout">@layout/activity_main_twopane</item>
          <bool name="twopane">true</bool>
      </resources>
      

    The Android system will take care of loading the proper layout file (either res/layout/activity_main.xml or res/layout/activity_main_twopane.xml) when your Activity loads the layout:

    setContentView(R.layout.activity_main);
    

    Just remember that the views that don’t exist in the single-pane layout will be null when you try to access them (e.g., there won’t be two ListViews anymore). Checking whether a certain View exists is one way to detect which layout you are using.

    Also note the use of optional Boolean resources in XML files. This is a handy way to pass the “is it a large screen or small screen” variable to your Java code. You can access Boolean resources in your Activity like this:

    boolean isTwoPane = getResources().getBoolean(R.bool.twopane);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that has some configuration settings stored in SharedPreference. Now I
This may seem like an obvious question but we have a PHP/MySQL app that
So I have an app that has a login screen with an image and
I have an App that has a toolbar at the bottom of the screen
I have an app that has a few setup screens that need to be
Like I am making an app that has to target for a particular screen
I have Rails 3.1.2 app with a hierarchical relationship that looks like this: Categories
Have an app that has listings - think classified ads - and each listing
I have an app that has different names for different languages. How do I
I have an app that has a centre view with two views off to

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.