I made an application for android and i have two languages (english – greek) and i want when the device has english locale to have different fonts than it has in the greek language.
I used
String loc = Locale.getDefault().getISO3Language();
to get the iso3Language (eng, ell, deu….) and then i used an if command
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);
}
but it doesn’t recognise it and even when i have english locale it executes the else part of the code!!
Can you help me please?? Thank you!!
In java, you can’t compare string using ==. Use the equals method instead.
This this tutorial for a more in depth answer.