I have a fairly simple app with 2 "layouts" using SharedPreferences.
Main has a textView that uses getString from SharedPreferences. Also a button to open Settings.
Settings has a spinner and a button to save to SharedPreferences.
The textView gets updated when the App loads as I am calling setText() inside onCreate(Bundle savedInstanceState)
When I open Settings and update the SharedPreferences, I use the Back button to get back to Main.
Since I am calling setText() inside onCreate() the textView does not update again until I exit the app and open the app again to main.
What method do I need to use to update the textView after coming back from Settings?
My request is similar to the viewWillAppear() for iOS.
onCreate() is only called once when the activity first starts. If you want to update text whenever the activity becomes active you can use onResume() instead. More information on the Activity lifecycle can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With