P
P
Pan Propan2021-05-26 13:58:58
Android
Pan Propan, 2021-05-26 13:58:58

Do I need to create a separate activity for each screen?

When creating a project in android with a preset menu, a project is created with one activity and with several fragments for each menu item.
If I myself try to add a new fragment + viewmodel combination, then android studio also creates another activity in addition.

I'm just starting to dive into android development and it's still not entirely clear.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Zagaevsky, 2021-05-26
@zagayevskiy

No, it doesn `t need. There should be one activity. There is one fragment per screen.

F
foonfyrick, 2021-05-27
@foonfyrick

It is possible on activity, it is possible on fragments, the main thing is to understand the difference, and why it is better on fragments.

D
Dmtm, 2021-05-27
@Dmtm

there is a good principle - a separate activity is started when it can be used as a standalone application,
for example - a calculator as part of an application can be designed as a separate activity and available for calling by third-party applications

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question