Fragment is trying to invoke the method of activity. After you turn over the data in the fragment and do something in the method, I want to return the value, but I want to make it like a static method, but I can't use the static method because I think there will be a problem with the activity. Is there any other way?
android android-fragments
From Fragment
(Activity class name) getActivity().public method of activity();
You can do it like this.
If you want to invoke the method of fragment in the activity
FragmentManager fm = getSupportFragmentManager();
//When you put the fragment in xml,
Fragment class name fragment = (Fragment class name) fm.findFragmentById (R.id.fragmentClassID);
public method of fragment.fragment();
You can do it like this.
© 2024 OneMinuteCode. All rights reserved.