//定义处
public enum TestItem
{
CPU,
MEMORY,
PROCESS,
BATTERY,
THREEG
}
//使用处
String TAG = "FlowWindow";
for(TestItem testItem:TestItem.values())
{
Log.i(TAG, "----------testitem--------------------- " + testItem.ordinal());
}
//log结果
02-23 14:43:34.730: INFO/FlowWindow(1706): ----------testitem--------------------- 0
02-23 14:43:34.730: INFO/FlowWindow(1706): ----------testitem--------------------- 1
02-23 14:43:34.730: INFO/FlowWindow(1706): ----------testitem--------------------- 2
02-23 14:43:34.730: INFO/FlowWindow(1706): ----------testitem--------------------- 3
02-23 14:43:34.730: INFO/FlowWindow(1706): ----------testitem--------------------- 4
java中枚举类型被看作类,和C中的枚举类型不同,开始用C中枚举类型去看待果然傻了。