B3nedikt / reword

Reword is a android library to update the texts of views when the apps texts have changed due to a language change or an update of the apps string resources.
Apache License 2.0
32 stars 7 forks source link

View are not updating on locale change if strings are provided using data binding #11

Closed ashu5398 closed 3 years ago

ashu5398 commented 3 years ago

If I have set a string from strings.xml to a textview using databinding library, then on a locale change strings are not getting updated without a recreate of activity. Can I get any help on this?

B3nedikt commented 3 years ago

Sure. Assuming you use both databinding and set strings resources directly in XML, you need something like this:

            Reword.reword(window
                    .decorView
                    .findViewById<ContentFrameLayout>(android.R.id.content))

            binding.invalidateAll()

"this" is your root activity here, "binding" is the databinding used at your root activity. Hope this helps :)

ashu5398 commented 3 years ago

That worked !! Thanks for help

B3nedikt commented 3 years ago

You're welcome :)