Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to set Locale to zh_HK android

I am facing issue with setting in app locale to zh_HK. The code Locale locale=new Locale("zh_HK") also not working and upon printing locales.getAvailable locales list, I am getting zh_HK_#Hans,zh_HK_#Hant. Further more setting Locale locale=new Locale("zh_HK_#Hans") is also NOT working.

in the printed list of available locales it has no option like zh_HK. I am importing java.utils.Locale.

like image 229
mradss Avatar asked Oct 20 '25 10:10

mradss


1 Answers

in your class that extands Application put this code :

public class myApp extends Application {
 @Override
    public void onCreate() {
        super.onCreate();
Locale locale = new Locale("zh","HK");
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
        getApplicationContext().getResources().updateConfiguration(config, null);
}
}
like image 110
Yessine Mahdouani Avatar answered Oct 23 '25 00:10

Yessine Mahdouani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!