package com.community.pocket.util; import com.community.pocket.R; import java.util.Locale; //语言类型 public enum LocaleType { auto(Locale.ENGLISH, 0, R.string.language_auto), chs(Locale.CHINA, 1, R.string.language_chs), en(Locale.ENGLISH, 2, R.string.language_en); //语言 private Locale locale; //类型值 private int type; //选项名对应的资源id private int resId; public Locale getLocale() { return locale; } public int getType() { return type; } public int getResId() { return resId; } LocaleType(Locale locale, int type, int resId) { this.locale = locale; this.type = type; this.resId = resId; } public static LocaleType getLocale(int type) { for (LocaleType t : LocaleType.values()) { if (t.type == type) { return t; } } return LocaleType.auto; } }