How to pass image data from one activity to another activity?

后端 未结 9 729
一生所求
一生所求 2020-11-30 14:26

I am using two activities. One activity displays images in a GridView and by clicking on a particular image in that GridView it should display the

9条回答
  •  爱一瞬间的悲伤
    2020-11-30 15:14

    In MyGridView: (someInteger is an integer that represents the index of the selected image

    Intent myIntent = new Intent(this, MyImageViewActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt("image", someInteger);
    myIntent.putExtras(bundle);
    startActivityForResult(myIntent, 0);
    

    In MyImageViewActivity:

    Bundle bundle = this.getIntent().getExtras();
    int pic = bundle.getInt("image");
    

    of course, you can put anything in the bundle! maybe a byte array or something

提交回复
热议问题