What is different between getContext and getActivity from Fragment in support library?

前端 未结 8 746
深忆病人
深忆病人 2020-12-02 15:39

What is different between getContext() and getActivity() from Fragment in support library?

Do they always return the same obje

8条回答
  •  旧巷少年郎
    2020-12-02 15:58

    @mlevytskiy Please check this Stactoverflow Answer. I hope it will helps you.

    getContext() - Returns the context view only current running activity.

    getActivity()- Return the Activity this fragment is currently associated with.

    getActivity() can be used in a Fragment for getting the parent Activity of the Fragment .

提交回复
热议问题