Lucas
Lucas

Reputation: 1246

Is it possible to use ViewModel with a Dialog class?

Our project has an Input Method Service. It is a custom keyboard where we call a Dialog to show some screens where the user is able to interact.

My question is:

Is it possible for a ViewModel to be used with Dialog class as we do it with Activity ?

Upvotes: 0

Views: 77

Answers (1)

shubhamgarg1
shubhamgarg1

Reputation: 2005

You can use Viewmodel if your dialog extends a DialogFragment class. Viewmodels can be used with both activities and fragments.

Upvotes: 1

Related Questions