Reputation: 157
I want to pass some data from one fragment to another and I have managed to successfully pass every single data except an imageView, I don't know how to do that. Here's my code below passing data:
1st fragment:
val action: NavDirections =
PartnersFragmentDirections.actionPartnersFragmentToPartnerItemFragment(
obj.name,
obj.short_description,
obj.connection_state,
obj.logo_path,
obj.id
)
findNavController().navigate(action)
2nd fragment
if (arguments != null) {
val arg = PartnerItemFragmentArgs.fromBundle(requireArguments())
binding.partnerName.text = arg.name
binding.partnerDescription.text = arg.shortDescription
connectionState = arg.connectionState.toString()
id = arg.id.toString()
Upvotes: 1
Views: 649
Reputation: 157
I found a solution about this using Glide.
if (arguments != null) {
val arg = PartnerFragmentArgs.fromBundle(requireArguments())
binding.partnerName.text = arg.name
binding.partnerDescription.text = arg.shortDescription
connectionState = arg.connectionState.toString()
val logoPath = arg.logoPath
Glide
.with(binding.partnerLogo.context)
.load(logoPath)
.into(binding.partnerLogo)
id = arg.id.toString()
}
Upvotes: 1