简体   繁体   中英

Update data from spinner activity in fragment and refresh

I have main activity like this:

MainActivity and ExampleFragment

I need to update my fragment when some one change something in spinner. I know i can use interfaces, and im using it in my application but in this case i cant do that. I searched some many topics in stackoverflow and there i found only this:

                        if (myFragment.getArguments() != null) {
                            myFragment.getArguments().putParcelable(Constants.USER,user);
                            myFragment.getArguments().putParcelable(Constants.PATIENT,pickedPatient);
                        }

I was trying detach and then attach my fragment to refresh, but data in bundle is not updated, and my fragment is just empty. I checked my logs and old data is still available.

Is there any solution for that problem? Or can I access my toolbar with spinner in my fragments and then update data in whole activity?

Some example with my another fragment here:

AnotherFragment

Create new Fragment instance for the myFragment like

myFragment = new MyFragment();

And use .replace method to change the fragment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM