N
N
Nick20152016-03-12 16:34:22
Android
Nick2015, 2016-03-12 16:34:22

Support for tablets (display 2 fragments)?

How to correctly implement support for the tablet version with a making structure:
There is a base activity from which all my other activities rely.
Let's say 1 activity passes the layout to the base and the fragment (A) that will open. It is necessary to make it so that in 1/3 of the screen there was that fragment A and in 2/3 that the detailing of the list (fragment B) would open. How to implement it? I understand that creating a layout that will place containers and load those fragments there, but share the material on how to do everything correctly and beautifully.
+ what to do with the implementation (with code) of a simple version (portrait) if so, fragments are replaced in 1 container ....
Sorry if I wrote something wrong! I will be very grateful!!!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Dorofeev, 2016-03-13
@Nick2015

Here is the source for the working example you need.
Taken from this book ( can be found online ).
In short:
1) Create two versions of layoutyours Activity(one in the folder layout( for smartphones ), and the other in the folder - layout-large( for tablets )). layoutFor tablets, insert not only fragmentwith your list of options, but also FrameLayoutto display information on the object from the list.
2) In the class Activityon clicking on an element of the list of options, write something like this code:

if (myFrameLayout != null) { // FrameLayout существует только в layout для планшетов
  showInforamtionAtDetailFragment(); //поэтому если он существует - показываем информацию во фрагменте
  else {
   openDetailActivity(); // иначе - у нас смартфон, потому что layout не существует;открываем отдельную Activity
  }

D
Denis Zagaevsky, 2016-03-12
@zagayevskiy

An example of what you want: developer.android.com/intl/ru/guide/components/fra...
Smoke this, retelling the contents of the docks without specific questions and problems is a little expensive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question