Deprecated updateConfiguration() - Android -




i defined layouts multiple languages , multiple devices below:

enter image description here

i set proper layout custom language bellow :

string languagetoload = "ar";  locale locale = new locale(languagetoload); locale.setdefault(locale); configuration config = new configuration(); config.setlocale(locale); getbasecontext().getresources().updateconfiguration(config, null); this.setcontentview(r.layout.activity_main); 

for language (ar - arabic) fetch layout-ldrtl or layout-ldrtl-sw600dp , other language (en - english) fetch layout-ldltr or layout-ldltr-sw600dp , above code work.

problem : in line getbasecontext().getresources().updateconfiguration(config, null); me updateconfiguration deprecated , use createconfigurationcontext when use method source don't work true , don't me proper layout .

resolved problem. use link in activity use bellow code :

context context = mycontextwrapper.wrap(this, "en"); layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view view = inflater.inflate(context.getresources().getlayout(r.layout.activity_main), null); this.setcontentview(view); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -