[수미수의 개발 브로구]

[Android] Fragment 간 Image 전달 본문

Language & Framework/Android

[Android] Fragment 간 Image 전달

수미수 2023. 9. 28. 23:11
반응형

개요

한 개의 Fragment 에서 다른 Fragment 로 이미지 전달 방법

FilePath 이용 방법

String stringUri = pictureFile.getAbsolutePath();
FreeFragment ldf = new FreeFragment ();
Bundle args = new Bundle();
args.putString("Image", stringUri);
ldf.setArguments(args);
getFragmentManager().beginTransaction().add(R.id.container, ldf).commit();

//In your NextFragment u can receive it and set as below

String imgPath = getArguments().getString("Image");
Bitmap bitmap = BitmapFactory.decodeFile(new File(imgPath));
iv.setImageBitmap(bitmap);

참고 사이트

반응형