我創建了以下方法:如何重新排序列表<String>
public List<String> listAll() {
List worldCountriesByLocal = new ArrayList();
for (Locale locale : Locale.getAvailableLocales()) {
final String isoCountry = locale.getDisplayCountry();
if (isoCountry.length() > 0) {
worldCountriesByLocal.add(isoCountry);
Collections.sort(worldCountriesByLocal);
}
}
return worldCountriesByLocal;
}
它相當簡單,它返回世界各國的用戶列表中的語言環境。然後,我將其排序以使其符合字母。這一切都完美的作品(除了我似乎偶爾會國家的副本!)。
無論如何,我需要的是把美國和英國在列表的頂部不管。我的問題是,因爲這是特定於語言環境,我不能隔離指數或將在美國和英國被返回的字符串!
任何想法將非常感激。
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Locale.html#getCountry() – MikeTheLiar