K
K
Konstantin Kanaev2014-06-15 14:18:52
Android
Konstantin Kanaev, 2014-06-15 14:18:52

Question about activity and fragment in android?

Please explain what is used for what.
Why, for example, is it impossible / possible to create one activity and then just change fragments? Or why it is impossible/possible to create a bunch of activities without fragments?
From what I read, I understood only one use of fragments - modularity. For example, we created one navigation drawer and can use it in different activities.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
IceJOKER, 2014-06-15
@IceJOKER

Fragments are good when the application is launched on different platforms with different resolutions, for example, there is an application with a menu and content, and so - fragments allow you to do so that -
on small screens, so that the menu is displayed first and shows content when pressed, but on large screens so that the menu is displayed on the left and the content on the right, which is very convenient.
Fragment - a piece that can be done once, and then used in different places)

A
Andrey M, 2014-06-15
@Collosteam

Use snippets where possible.
For example, for grouping functionality (fragment1 - a list of articles on the resource, and fragment2 - the articles themselves) they will have a common activity. Further, when implementing the tablet display mode, you can very simply organize the UI.
Good application example

M
Mintormo, 2014-06-16
@Mintormo

And who said that it is impossible? You can create one activity and change fragments. Technically it's perfectly acceptable. Before 3.0, in general, everything was built only on activation. So it's very possible. You need to look at what is more convenient and expedient.

R
Rustem Saitkulov, 2015-01-19
@atetc

This is a violation of the SOLID principles.
You will have a lot of implementation in one class + you yourself will get confused (tormented) with BackStack.
P.s. or write your activity as in Telegram.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question