I'm passing a string value, which is also the name of an image in the drawable folder using intent.putExtra. The string is then successfully pulled from the onCreate of the intended class.
But I'm wondering how I can set the passed over string message as the image name when setting the Image Resource of the image view for that activity.
I'm guessing that the message variable needs to be cast or converted before I use it to set as an image resource name.
Does anyone have any advice on how to achieve this?
This is what I've tried so far in said activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_result);
imageView = (ImageView) findViewById(R.id.capturedDebriImageView);
Bundle bundle = getIntent().getExtras();
//contents of message is "aluminium"
String message = bundle.getString("message");
imageView.setImageResource(R.drawable.message);
//if I set it as the actual image name it works but not when
//I set the image resource to the message which contains the string of the
//same name.
imageView.setImageResource(R.drawable.aluminium);
}