There is a class of type Enum and I want to make a switch for it, but the constant expression required tells me.
Those. this way works
if (item.getType() == ItemType.TEXT) { } but this does not work
switch (item.getType()){ case ItemType.TEXT: } and so it also works
switch (item.getType().toString()){ case String.valueOf(ItemType.TEXT): } Here is the enum class itself
public enum ItemType { TEXT,PHOTO,EMPTY; }
case ItemType.TEXTdoesn't work), but the switch with String appeared relatively recently. Probably you have an android of the wrong system. On the other hand, the callString.valueOf(ItemType.TEXT)cannot be called aconstant expression. Need to write"TEXT"- Sergey