New to Android here, so I apologize if this is a simplistic question.
I am attempting to use a switch based on string resources in my XML. It would look something like this:
switch (myStringVariable) {
case getResources().getString(R.string.first_string):
break;
case getResources().getString(R.string.second_string):
break;
case getResources().getString(R.string.third_string):
break;
default:
break;
}
Unfortunately, this won't work. The error that I get is "Constant expression required".
Is there a semi-elegant way to go about this, without having to do something like create 3 String objects and assign the string resources to each object? I feel like I'm missing something obvious, so any assistance would be great!
Thanks :)