When do you use Android snippets?

I need to write a simple application that will look different depending on the screen size.

On a small screen, it will have a list of items, and after clicking, it will display the details. On the big screen, he will have a list of objects and parts next to him.

My question is: should I use fragmentsto create such an application or just write different layouts and place them in folders layout-largeor layout-land?

+4
source share
3 answers

If this is a new application, I will always use fragments, mainly for future verification of your application. Now you may have one list, but later you might want to enter a menu to select different types of lists, for example. Using fragments, on the phone you can use two actions: one for the selection and the other for the list, but on the tablet in landscape mode you can put the selection and list it side by side.

Coding for possible improvements and features of the application now saves time and headaches later.

+3
source

You can do this in both directions, but the proposed solution uses a fragment

check this out: https://developer.android.com/training/basics/fragments/fragment-ui.html

and this:

http://www.vogella.com/tutorials/AndroidFragments/article.html

+1

You should use Fragments, because fragments were created for this purpose, in addition, if you make 2 layouts, you will need to make 2 completely different layouts, and this will mean that the activity will not handle this, at least not in simple way, so try snippets to achieve this, the official documentation example is a case like yours, this would be enough to believe that the correct way to do this is with snippets.

+1
source

All Articles