Since the Android getFragmentManager() API is deprecated, is there any alternative?

前端 未结 12 1549
梦毁少年i
梦毁少年i 2020-12-05 06:47

FragmentManager is deprecated. Is there an alternative or what can I do now?

 PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocomplet         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 07:24

    If I understood you well getFragmentManager() is now deprecated

    we will use getChildFragmentManager() Return a private FragmentManager for placing and managing Fragments inside of this Fragment.

    we will use getParentFragmentManager() Return the FragmentManager for interacting with fragments associated with this fragment's activity.

    so, if you deal with fragments inside a fragment you will use the first one and if you deal with fragments inside an activity you will use the second one.

    you can find them here package androidx.fragment.app;

提交回复
热议问题