Deprecated updateConfiguration() - Android -
i defined layouts
multiple languages , multiple devices below:
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
Post a Comment