Passing Assigned Value Of A Spinner From Fragment To Fragment Within Viewpager Nullpointerexception
I've make it more simple and updated it based on the answers in my previous post: Adding Assigned Values in Spinner NullPointerException I have a MainAcitivty that uses a ViewPager
Solution 1:
Here is a simple way to communicate between fragments.
In MainActivity, keep static instances of the fragments.
publicstatic FragA fragmentA;
publicstatic FragB fragmentB;
Now if you want to access FragB from FragA, write something similar:
((MainActivity) getActivity()).fragmentB.setSomething();
And Here is a better/proper way to communicate between fragments:
http://developer.android.com/training/basics/fragments/communicating.html
Post a Comment for "Passing Assigned Value Of A Spinner From Fragment To Fragment Within Viewpager Nullpointerexception"