How can I pass a Bitmap object from one activity to another

前端 未结 10 939
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 03:39

In my activity, I create a Bitmap object and then I need to launch another Activity, How can I pass this Bitmap object from the sub-ac

10条回答
  •  死守一世寂寞
    2020-11-22 03:52

    You can create a bitmap transfer. try this....

    In the first class:

    1) Create:

    private static Bitmap bitmap_transfer;
    

    2) Create getter and setter

    public static Bitmap getBitmap_transfer() {
        return bitmap_transfer;
    }
    
    public static void setBitmap_transfer(Bitmap bitmap_transfer_param) {
        bitmap_transfer = bitmap_transfer_param;
    }
    

    3) Set the image:

    ImageView image = (ImageView) view.findViewById(R.id.image);
    image.buildDrawingCache();
    setBitmap_transfer(image.getDrawingCache());
    

    Then, in the second class:

    ImageView image2 = (ImageView) view.findViewById(R.id.img2);
    imagem2.setImageDrawable(new BitmapDrawable(getResources(), classe1.getBitmap_transfer()));
    

提交回复
热议问题