[android-developers] switch case using string from Enum

2014-07-18 Thread sweety fx
*I have the below enum:*

public enum Type {

TYPE_ONE(event/one);
TYPE_TWO(event/two);

private Type(String mType){
this.mType = mType;
}
private final String mType;

public String getType(){return mType;}
}

*I am trying to compare in Switch/Case:*

 switch (event.getType()){
case Type.TYPE_ONE.getType():  // says 
Constant expression required
Do something:
 case Type.TYPE_TWO.getType(): //  says 
Constant expression required
Do something;
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Switch case on String

2009-09-24 Thread Abhi

Can I do a switch(String), case (compare with other string) and how?

I am trying to compare string results and perform actions...

Thanks,

Abhi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---