简体   繁体   中英

Fragment doesn't refresh

I have a Fragment that shows some data saved in android Preference . when these data changes due to various operations of the app, I want to update the fragment with the new data.

I have tried to use

myFragmentTransaction.notifyAll();

But unfortunately doesn't work and the fragment is updated only when I reopen my whole Activity

Houw could I refresh the Fragment on data changes?

notifyAll pertains to threading. Completely unrelated to what you are doing. Instead of trying to tell each fragment to redraw themselves have you tried OnSharedPreferenceChangeListener . Each fragment should listen to changes in the information they care for.

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