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.
what i’ve done (more or less, i don’t have my code in front of me),
i put my image file in assets, then i create my method around :
this reads file from assets and convert this to Bitmap
you coulkd also use context.getResources() but i don’t remember what to do next