码迷,mamicode.com
首页 > 移动开发 > 详细

Android 怎么自定义枚举类型的值

时间:2015-06-05 11:40:47      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

 

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 "";
}

 

Android 怎么自定义枚举类型的值

标签:

原文地址:http://www.cnblogs.com/jovita21/p/4553946.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!