KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to display a message to the user depending upon a prompt I receive from another part of the program. There can be a number of prompts & they are stored in an enum. These are my prompts: Defs.java public enum Prompt { PromptA, PromptB, PromptC, } I have the externalized strings stored in resources on these lines: res/values/strings.xml <string name="PromptA">Error in execution</string> <string name="PromptB">Process completed successfully</string> <string name="PromptC">Please try again</string> Now in my main Activity screen a method is called by some other part: public void showPrompt(Prompt prompt) { String message = getString(R.string.<**what-do-I-put-here?**>); //show a dialog box with message } I know this can be done with a huge if-else block (there are tons of prompts in the actual application) or a switch statement. It will be really ugly. Is there a better way to do this?
Tags (comma-separated)
Save Edits
Cancel