Dilemma: when to use Fragments vs Activities:

后端 未结 14 696
失恋的感觉
失恋的感觉 2020-11-22 11:58

I know that Activities are designed to represent a single screen of my application, while Fragments are designed to be reusable UI layouts with log

14条回答
  •  情话喂你
    2020-11-22 12:15

    Well, according to Google's lectures (maybe here, I don't remember) , you should consider using Fragments whenever it's possible, as it makes your code easier to maintain and control.

    However, I think that on some cases it can get too complex, as the activity that hosts the fragments need to navigate/communicate between them.

    I think you should decide by yourself what's best for you. It's usually not that hard to convert an activity to a fragment and vice versa.

    I've created a post about this dillema here, if you wish to read some further.

提交回复
热议问题