Can a DataBinding interfere with the localization of an Activity?

TL; DR

I have an application that supports multiple languages. One action is not translated, despite the use of all the usual localization methods. This is the only activity in the application that fully utilizes DataBinding .

Full explanation

I have an Activity that uses a DataBinding . Thus, in general, the entire XML layout for this activity is wrapped inside the <layout> . This is how I inflate the view and get the binding:

SomeActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.some_activity);

In XML there is TextViews text that has the following text:

... android:text="@string/<name of a string>" ...

We provide the user with predefined language settings and set the application localization using

Locale.setDefault(new Locale("<language name>"));

In English, everything works fine.

When the application is in a different language, think that the lines in the activity in question are still displayed in English - even if these lines were translated into the corresponding language and located in the same line files where the rest of the application captures lines from. Until this activity is launched, the application will be fine - after the action begins and I return from it, the application will return to English before it is destroyed and restarted. If this activity never opens, the application behaves as expected.

Can anyone understand what could be causing this? Thanks.

+8
android android-activity android-location data-binding android-databinding
source share
1 answer

I found out what was going on. This has nothing to do with ViewBinding. This activity starts in landscape mode, which for some reason resets the application locale. This answer helped me fix this.

-2
source share

All Articles