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

前端 未结 6 1646
花落未央
花落未央 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:44

    One big thing all the above comments don't mention is that a fragment remains resident in memory even if Android kills the activity and restarts it when you do something like change the orientation of your device. This is done for performance reasons but can also lead to unexpected results if you were expecting fragments to be destroyed only to find that they are getting recreated out of nowhere.

提交回复
热议问题