Stack Overflow Asked by Aaron Waller on December 23, 2020
I want to simply call a fragment method inside my MainActivity.
Sound simple but in my case I can’t use the FragmentManager to call it because I have a TabView in my app, so I have to call the TabFragment which manages all the other tab Fragments first:
mFragmentManager = getSupportFragmentManager();
mFragmentTransaction = mFragmentManager.beginTransaction();
mFragmentTransaction.replace(R.id.containerView, new TabFragment()).commit();
Normaly I would simply use .commitNow() to call the fragments method afterwards.
But in my case I don’t want to call a method out of my TabFragment but out of a Fragment which gets called inside the TabFragment.
How can I achieve this?
I already tried an interface but got nullPointerExceptions all the time, is an interface the right way to do it?
Here is my previous question where I explained how I used the interface which did not work for me:
How to use interface to communicate between fragment and activity?
Thanks
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP