Hello, I'm a beginner at Android.
We have created and used fragments to eliminate the hassle of moving from the main activity to other activities. I want to show you the activity screen again.
Is there any other way to get rid of the fragment than to adjust it in the main activity?
I just want to get rid of the fragment itself. Help me
android fragment
If you add a fragment in MainActivity, in Fragment
You can call functions in MainActivity as follows:
When MainActivity has the following function,
...
public void destroyFragment() {
...
}
...
You can call in the following way.
((MainActivity)getActivity()).destroyFragment();
Yes, you need to access Fragment Manager
to remove the fragment.
I think you are managing Fragment Manager in the main activity To access at the Fragment level, you may need to share the FragmentManager object or the MainActivity object.
However, there is a Event Bus
library that calls between Fragment and Activity.
http://gun0912.tistory.com/4 to.
© 2024 OneMinuteCode. All rights reserved.