Join Slack
Does anyone have a way to instantiate a DialogFragment with an lambda?
# android
j
John
02/04/2020, 1:51 PM
Does anyone have a way to instantiate a DialogFragment with an lambda?
google
1
John
02/04/2020, 1:51 PM
Neither an
interface
or a function can be parcelized nor serialized
s
Shmuel Rosansky [G]
02/04/2020, 2:35 PM
It's error prone to attach a lambda to a fragment
Shmuel Rosansky [G]
02/04/2020, 2:36 PM
The operating system can recreate your fragment anytime
Shmuel Rosansky [G]
02/04/2020, 2:36 PM
The lambda that you've set will be null the fragment is retreated. It's very likely to crash at runtime
Shmuel Rosansky [G]
02/04/2020, 2:37 PM
If you want some sort of callback either use a view model to communicate or have the activity implement an interface
Shmuel Rosansky [G]
02/04/2020, 2:37 PM
2 possible solutions
6
Views
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by