Android - how can i transfer ImageView from one activity to another activity?

后端 未结 3 1113
独厮守ぢ
独厮守ぢ 2021-01-25 04:49

I have Activity1 which have one ImaveView including image preview. Once i press the button i go from Activity1 to Activity2. In Activity2 i do not have image preview but an opt

3条回答
  •  滥情空心
    2021-01-25 05:02

    There are many way to solve this problem. And here are 2 simple ways:

    The first, you can read more about SharedPreferences

    The second, you can putExtra bitmap from this Activity to another activity like this:

    putExtra:

    intent.putExtra(BITMAP_SHARED_KEY, yourBitmap);
    startActivity(intent);
    

    getBitmap which you've shared

    Bitmap bitmap = (Bitmap) intent.getParcelableExtra(BITMAP_SHARED_KEY); // BITMAP_SHARED_KEY = "bitmap_shared_key"
    

提交回复
热议问题