Refresh fragment when change between tabs

前端 未结 5 2171
难免孤独
难免孤独 2021-01-04 05:54

App open on first fragment and there is 2 tabs i want to refresh second fragment when i move to it but i don\'t want to refresh first fragment

MainActivity

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-04 06:00

    As of 2020 it is advisable to use architecture components(MVVM) such as LiveData and viewModel

    This way all Fragments can share the same state

    see docs here https://developer.android.com/jetpack/guide

提交回复
热议问题