我为android做了一个应用程序,我有两种语言(英语-希腊语),我希望当设备具有英语语言环境时,其字体与希腊语不同。
我用了
String loc = Locale.getDefault().getISO3Language();
获得 iso3Language (eng, ell, deu ....) 然后我使用了 if 命令
if(loc=="eng"){
Typeface font1 = Typeface.createFromAsset(getAssets(), "MISTRAL.TTF");
txt1.setTypeface(font1);
txt1.setText(R.string.app_name);
}
else{
Typeface font1 = Typeface.createFromAsset(getAssets(), "SNAP.TTF");
txt1.setTypeface(font1);
txt1.setText(R.string.app_name);
}
但它无法识别它,即使我有英语语言环境,它也会执行代码的 else 部分!你能帮我吗??谢谢!!