Home > Enterprise >  why my image view and text view in secomd framgent empty?
why my image view and text view in secomd framgent empty?

Time:01-07

i get list of image and text data from api in first fragment then when user pick image it's go to second fragment and show image and textfirst-fragment github.com/AzAlhobayyeb/Images.git i tried to link fragments with live data didn't use argumentssecond-fragment

CodePudding user response:

it's like the imagePicked in the 2nd Fragment is null.I think the reason the viewModel is recreated in 2nd page.

Solution :

In the ImageDetailsFragment you using :

    private val viewModel: ImageViewModel by viewModels()

change to this :

    private val viewModel: ImageViewModel by activityViewModels()
  • Related