H
H
HolodnoDev2020-04-23 07:46:53
Android
HolodnoDev, 2020-04-23 07:46:53

Android, when changing the language in the system, not all resources are updated, what should I do?

Hello. There is an activity with a form for creating a record - text fields, autocomplete, checkboxes, captions for all this, etc.
The string resources are written in two languages.
If you minimize the application, change the language in the system and go back, the following happens:
- in general, string resources are switched to the desired language
- the text in the autocomplete does not switch, when you click on the field, the autocomplete list does not drop out (although I looked with the logcat, it is there). I tried to do manually setText, nothing happens. In general, it is not clear on what event the string resource in the widget is updated and how to catch it.
- the standard validation message in the text field, if it came out before switching the language, does not change the text either. if you call the validation message again, it will already be with the correct language.

In general, a complete mess. So I'm thinking - either force reload the activity (but then it's not clear what to do with user input), or make some kind of crutches for validation and autocomplete.

I also tried to catch the broadcast message about changing the language, but there is no sense in this, because it comes when the application is still minimized, and the resources are updated when the activity appears on the screen.

I saw this topic https://qna.habr.com/q/12584, but the question remained.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Vodakov, 2020-04-23
@WaterSmith

because it comes when the application is still minimized, and the resources are updated when the activity appears on the screen.

First you need to use MVP or MVVM
For example, if you have MVVM, you will be notified when the language changes, change the state of the view model, and when you open the activity, update it according to the new state.

I
Ilya Pavlovsky, 2020-04-23
@TranE91

Very similar to solving the problem:
https://stackoverflow.com/questions/18365354/local...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question