NavigationDrawer with Activities vs. NavigationDrawer with Fragments

前端 未结 3 534
有刺的猬
有刺的猬 2020-12-25 15:21

Take for example the app I\'m currently working on: - it has an navigationDrawer with multiple items; there are two items which interest me for now, i\'ll call them X and Y

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 15:46

    I have the following points to submit:

    1. The fragment approach is much better. You should use fragments for better UI experience for the user.

    2. Think like this, imagine your screen as a basket of information and if you have another basket(i,e another screen) with which a lot of data will have to be transferred to and fro, then, according to me, it is much better to use fragments for the two baskets along with a container activity. And of course there can be more than two baskets/screens.

    3. There is no hard and fast rule that you should use only use fragments or activities, but google says that it is much better to use fragments where ever it is possible.

    4. Generally, developers use fragments to group associated logic together and it is much better to do it this way as it will provide a logical grouping of whatever you are trying to do.

    5. It is also easy to pass java data objects among fragments via the container activity and with the help of Interfaces. This is also considered a very modular approach.

    Rest depends on how you would like to define the flow of your application. I think using fragments is a much better approach in your scenario. Use container activities wherever you think that the associated logic has changed drastically.

提交回复
热议问题