So, I have a string array of some random saying and the like, but I would like to be able to do something different some of them, such as open a URL. I’ve been racking my brain trying to come up with the best way to do this. I want the ability to add new things, remove some, without having to worry about touching my code, unless perhaps there was a new action or something. The best possible thing I could think of would be to somehow have a multiple dimension string array, so that I can use the strings in the first column, and the action from the second column. Is there a way to do this?
Alternatively, is there a better way to do what I want?
No, sorry. Moreover, IMHO, it does not fit your described data model, as “I can use the strings in the first column, and the action from the second column” to me describes two independent string arrays. It may be that I am misinterpreting you, though.
If you really do have a dependency between the “columns” (i.e., for each string in the “first column” there is a distinct and largely unique set of actions from the “second column”), use an XML resource in
res/xml/, with a structure like:If you need to internationalize the strings, just have separate translations in the XML (e.g.,
res/xml/,res/xml-es/,res/xml-zh).