Android 怎么自定义枚举类型的值
public enum PayWay {
Online(1, "在线"), Money(2, "现金"), POS(3, "POS机支付);
private int nCode;
private String way;
private PayWay(int nCode, String way) {
this.nCode = nCode;
this.way = way;
}
public int getnCode() {
return nCode;
}
public void setnCode(int nCode) {
this.nCode = nCode;
}
public String getWay() {
return way;
}
public void setWay(String way) {
this.way = way;
}
@Override
public String toString() {
return "payWay{" +
"nCode=" + nCode +
", way='" + way + '\'' +
'}';
}
public static String valueOf(int type) {
PayWay payWay[] = PayWay.values();
for (int i = 0; i < payWay.length; i++) {
PayWay pw = payWay[i];
if (pw.getnCode() == type) {
return pw.getWay();
}
}
return "";
}