My ultimate goal is this: I have two spinners, spinner1, spinner2
, each with their own values. One image, named image
. There are strings, named start, end, file
. One button, button
.
My code looks as such:
@Override
public void onClick(View v) {
start = sStart.getSelectedItem().toString();
end = sEnd.getSelectedItem().toString();
if (start.equals(end)) {
Toast.makeText(this, "You cannot end where you start.",
Toast.LENGTH_SHORT).show();
works = false;
}
if (works) {
start = start.replace(" ","_");
end = end.replace(" ","_");
file = "@drawable/" + start + end + ".gif";
}
}
The file name matches the contents of start + end + ".gif"
perfectly, so I would like to set the image to the file name which corresponds to the string's content.