How to send the bitmap into bundle

后端 未结 5 975
北荒
北荒 2021-02-02 16:11

I\'m new to android. I want to pass bitmap into Bundle. But I can\'t find any solution for it. Actually, I\'m confused. I want to display an image in a Dialog fragment. But I do

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 16:32

    if you are using NavigationComponent, you should use safeArgs !

    you can put arguments in nav_graph like this :

    
    

    and send it like it : (First Fragment)

    findNavController().navigate(SettingFragmentDirections.actionSettingFragmentToHomeFragment(bitmap))
    

    and give it like this : (Second Fragment)

     val bitmapimage =
                arguments?.getParcelable("profileImage")
    
    
            user_profile_img.setImageBitmap(bitmapimage)
    

    read more : https://developer.android.com/guide/navigation/navigation-pass-data

提交回复
热议问题