Android best practices for Fragment to Activity communications

后端 未结 5 1681
误落风尘
误落风尘 2021-01-18 10:42

I am new to Android Fragment and trying to learn Fragment to Activity communications. What is the better approach(best practice) in Android for Fragment to Activity communic

5条回答
  •  旧巷少年郎
    2021-01-18 10:51

    The interface approach works fine and is more flexible in so far as it doesn't tie your fragment to the activity directly. One thing you should also consider is how much work the activity might need to do, that is it may end up managing several fragments. This has a tendency to lead to 'fat fragments' as my question here asked when I started using them

提交回复
热议问题