I looked at various Q & As on SO similar to this question, but could not find a solution.
I have an enumeration representing various ways to watch a TV guide ...
In the NDroid Application class
static enum guideView { GUIDE_VIEW_SEVEN_DAY, GUIDE_VIEW_NOW_SHOWING, GUIDE_VIEW_ALL_TIMESLOTS }
... when the user changes the view, the event handler gets an int from 0-2, and I would like to do something like this ...
In the Android Activity onClick(DialogInterface dialog, int which) event handler onClick(DialogInterface dialog, int which)
// 'which' is an int from 0-2 switch (which) { case NDroid.guideView.GUIDE_VIEW_SEVEN_DAY: ... break; }
I'm used to C # enumerations and select / case statements that would allow something like the above, and I know that Java does things differently, but I just can't figure out what I need to do.
Do I have to resort to if ? There will probably be only 3 options, so I could do it, but I was thinking how this can be done using a switch in Java.
EDIT Sorry, I didn’t fully solve this problem, because I saw it as a general problem with Java. I added to the question to explain a little further.
There is nothing special in Android, so I did not mark it as Android, but the enumeration was defined in the Application class, and the code in which I am disabled is in Activity . The enumeration is static, since I need to access it from several actions.
java enums switch-statement
Squonk Nov 13 2018-11-11T00: 00Z
source share