Tiago Palmas
Tiago Palmas

Reputation: 345

Kotlin setTargetFragment

I'm having problems to call a dialog callback. I am using:

class PerfilFragment : Fragment() {
   val fragment = MyDialog()
   fragment.setTargetFragment(**this**, 1)
   val fm = activity.fragmentManager
   fragment.show(fm, "myfragment") 
}

but the setTargetFragment method asks for a fragment and not my running PerfilFragment:

Type mismatch - Required: fragment, found PerfilFragment

Upvotes: 1

Views: 1024

Answers (1)

Rajan Kali
Rajan Kali

Reputation: 12953

Check whether both Fragments are from same library, because some times casting app.Fragment to a v4.Fragment might cause this kind of issues.

Upvotes: 2

Related Questions