2012-08-25 48 views

回答

3

您可以使用getAvailableLocales()來獲取Locale的數組,然後遍歷它以查看它是否可用。

boolean hasLocale = false; 
String myLocale = "en"; 
Locale[] locales = Locale.getAvailableLocales(); 
for (Locale locale : locales) { 
    if (locale.getLanguage().equals(myLocale)) { 
     hasLocale = true; 
    } 
} 
// Value of `hasLocale` is what you want here!