5

I am making an application and I just began using Fragments finally, after reading all of the documentation, I got to here. I designed the application so in portrait mode it is two activities, the chooser and the details, while in landscape left is chooser right is details, on a tablet. Now, this works fantastic like in this image: enter image description here

however, now when I turn the Handset into landscape, it does the same thing as tablet does in landscape, has the two fragments. First, I would like to know should I leave it as the two fragments on the handset too? Would this be the "best practice"? If not, I would like to know how to go about making the landscape like the portrait without messing up tablet landscape.

Thanks

Community
  • 1
  • 1
Samuel
  • 4,337
  • 3
  • 29
  • 35

1 Answers1

0

You'll need to have two separate layouts, one in a layout-port (for portrait) and one in layout-land (for landscape). Your portrait layout should contain just one fragment. In your activity you'll need to check for the presence of that fragment, or the view that contains it (if you are using FrameLayouts), and act accordingly.

See this from the developer site.

Flynn81
  • 4,108
  • 29
  • 28
  • If you're concerned with tablets, there's no hard and fast rule to determine which device is a tablet or not. You can say in your activity if the height is greater than 5 inches, treat it like a tablet. Getting device height has been asked before, see http://stackoverflow.com/questions/2193457/is-there-a-way-to-determine-android-physical-screen-height-in-cm-or-inches. – Flynn81 Jun 17 '12 at 13:35