Search code examples
javaandroidandroid-studio

Can I create only one activity with no fragments that handles the whole app?


I recently made an app that contains tons of activities performing different functions so I was wondering, can I create only one activity. No fragments nothing, only one activity that changes every time I want it to by maybe making views visible or removing and adding buttons whenever I need them? Or will that slow my app down?


Solution

  • No it won't slow your app down. Infact, it is better than having multiple activities in terms of efficiency because laying out and creating a new activity is obviously expensive.

    But of course, when it actually makes sense to have 2 activities, you should make two activities because that would make the code more modular, more readable and easily editable.

    So you have to strike a balance between efficiency and readability.