我想将应用程序中的所有数字格式化为阿拉伯数字(١٢٣٤٥٦٧٨٩),所以我考虑将地区设置为阿拉伯语和区域的组合:埃及而不是阿拉伯语,但不幸的是,出于某种原因,没有设置地区。
我把我的地点设置成这样:
Locale myLocale = new Locale("ar_EG");
Locale.setDefault(myLocale);
Configuration config = new Configuration();
config.locale = myLocale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
我的strings.xml放在一个名为“Val值-ar”的文件夹中。
我做错什么了?
先谢谢你。
发布于 2019-06-20 10:02:54
Locale类可以接收1、2或3个参数,但最好使用2个参数(语言、国家)来更改右到左语言(即)的文本和数字格式和方向。
我用这种方式解决了这个问题:
Locale myLocale = new Locale("ar","EG");
Locale.setDefault(myLocale);
Resources res = getApplicationContext().getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.setLayoutDirection(myLocale);
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
https://stackoverflow.com/questions/48177031
复制相似问题