Reputation: 341
I Have a button with a top drawable image, onclicking the button a intent is created i want to pass this drawable to the intent. How to do it pls help me out thanks in advance..
Button
Image to be showed on next activity
Upvotes: 0
Views: 473
Reputation: 4958
Assuming that your buttons are all atrological signs, and that you know what image resource you are using for each, why don't you just assign all your buttons the same onClick listener, and use a switch case to determine which sign it is.
public void onClick(View v) {
Intent i = new Intent(this, yourSecondActivity.class);
switch(v.getId()){
case R.id.ariesBtn:
i.putExra("sign", "aries");
break;
case R.id.cancerBtn:
i.putExtra("sign", "cancer");
break;
}
startActivity(i);
}
Then in your other activity check for extras "sign" and act accordingly
Upvotes: 2
Reputation: 345
Try this:
@drawable/filename
or post the code to better undertastand
Upvotes: 0