Greetings, I use PlaceholderFragment , in general, I have more than 40 fragments with the same View elements that are filled from the database. I implemented DialogFragment as a settings window, and through it I change the text size of my View elements, write these values to SharedPreferences when destroying DialogFragment , I get these values in the onCreateView method of my fragments. Faced such a problem, when I change the text size, the changes in the current fragment take place immediately, but as I scroll once, there are no changes yet, you need to scroll through the ViewPager twice so that the changes take effect in all the fragments. I understand this is due to the fact that the ViewPager stores in the previous, current and next fragments. The question is how do I, when changing the size of the text along with this, overload those fragments that are stored in the memory of the ViewPager ? Or where should I place the receipt of the value from the Preferences so that the changes would fall into those fragments that are stored in memory? The onCreateView method in which I receive them and pass to my View elements is triggered only through a fragment.
- onePerhaps you can help OnSharedPreferenceChangeListener . Subscribe to changes in the fragment and change the font size. - eugeneek
|
1 answer
Solved the problem as follows, in the adapter ViewPager added:
public int getItemPosition(Object object){ return POSITION_NONE; } And in the onDissmis DialogFragment method, when the selected font size values are saved in SharedPreferences added:
myViewPager.getAdapter().notifyDataSetChanged(); |