Call Activity Method From Fragment

后端 未结 5 941
南笙
南笙 2021-01-14 10:12

I\'m dealing with fragments.
I have an Activity and different fragments.
Each fragment need the access to a Class(call i

5条回答
  •  隐瞒了意图╮
    2021-01-14 10:34

    you have to Additional cast need to be done:

    Activity activity123 = getActivity();
    
    if(activity123 instanceof ParentActivity) {
        ((ParentActivity) activity123).someMethodInParentActivity();
    }
    

提交回复
热议问题