How do I call a method with the contents of a string? I have say 4 strings:
swimming
football
rugby
hockey
And I also have 4 methods called:
swimming
football
rugby
hockey
I have a listview with these strings filling the listview (this is just an example, i actually have a listview with 200 strings) So for the 200 strings, instead of writing an if statement:
if(string.equals("Swimming")){swimming();}
Can I make it someway that I can have one onclick method that, when an item in the listview was clicked it would run something like:
[string]();
Where [string] is some code to get what string was chosen from the listview
basically to save myself writing 200 if statements, could i have it so it automatically starts the method named after the string?