-2

How can I send image res to another Activity - How change Resources to integer? i create class to pass Image Resources to another activity:

public class MyImageView extends ImageView implements View.OnClickListener {

Context contxt;


public MyImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setOnClickListener(this);
    this.contxt = context;
}


public MyImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setOnClickListener(this);
    this.contxt = context;
}


public MyImageView(Context context) {
    super(context);
    setOnClickListener(this);
    this.contxt = context;
}


@Override
public void setOnClickListener(OnClickListener l) {

    super.setOnClickListener(l);
}


@Override
public void onClick(View v) {

    int g = getResourse......................;(this is my peroblem)
    Bundle extras = new Bundle();
    extras.putInt("imagebitmap", g);
    Intent i = new Intent(contxt, zara.knauf.Img.class);
    i.putExtras(extras);
    contxt.startActivity(i);

}
}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
ayoob zare
  • 76
  • 5
  • You are mispelling resour**c**e to resour**s**e. I don't know if it helps, but it could generate issues in your code. Anyway, simlpy pass the **id** and retrieve the resour**c**e in the called Activity. DONE. – Phantômaxx Jul 09 '17 at 17:31
  • [Here you can find your answer.](https://stackoverflow.com/questions/11519691/passing-image-from-one-activity-another-activity) this is already solved hope this will help you. – Irfan Babar Jul 09 '17 at 17:31
  • @Ifran That's not passing a resource id – OneCricketeer Jul 09 '17 at 17:32

1 Answers1

1

Simply set g to a R.drawable integer value. You don't need to call getResources.

You also don't need to create a Bundle object.

See How to pass integer from one activity to another?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245