Вопрос

Situation

I have a fairly simple app with 2 "layouts" using SharedPreferences.

  • Main.xml
  • Settings.xml

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)

Problem

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.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top