What is the benefit of using Fragments in Android, rather than Views?

前端 未结 6 1652
花落未央
花落未央 2020-11-28 18:51

When developing for Android, you can set your target (or minimum) sdk to 4 (API 1.6) and add the android compatibility package (v4) to add support for Fra

6条回答
  •  无人及你
    2020-11-28 19:43

    1. Scenario Activity Split screen - We have One Layout and one activity which handle left right screen part
    2. Scenario FragmentActivity we have One layout for Main screen, one for left one for right

    Scenario one is good if you have simple application.

    Scenario two is good if you want to have Multiple Fragments and multiple FragmentActivities and you can combine each of those. Also you can make interaction between fragments.

    I have split screen Fragmentactivity i can call it with 'Intent Extras' and tell to fragmentActivity which fragment are to be loaded. Fragments are good because they are not in manifest so you could make reusable fragments and FragmentActvity.

    But it make your project larger. But if you make large project you can save many. Because you can use same Fragments or same Fragment activity.

    And i thing that this fragments come little late so you must try to think in new way. Maybe just try to convert your activity to FragmentActivity. Later try to find reusable code and make Fragment from it.

    Its usefull but i dont know how right now. But i have some ideas.

    This is always problem. Android Team made somethink and nobody know what is good for. Because we are hardly learn like it was and here it comes some new things.

    In my opinion it is good but not for reason that google tell us.

提交回复
热议问题