Doubt about a Fragmentstateadapter constructor

Asked

Viewed 28 times

0

Fragmentstateadapter has three builders according to the documentation.

(@Nonnull fragmentActivity: Fragmentactivity)

(@Nonnull Fragment: Fragment)

(@Nonnull fragmentManager: Fragmentmanager,@Nonnull Lifecycle: Lifecycle)

In my class I’m using the first, that way:

class PagerAdapter(val fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {

...

}

And I hereby instate in Mainactivity:

pager.adapter = PagerAdapter(this@MainActivity)

this@MainActivity which is an Appcompatactivity is passed as parameter, android studio does not point out as error and the app works normally.

The question is my Mainactivity shouldn’t it be a Fragmentactivity? Are there scenarios that I might have some kind of problem with this type of implementation? Remembering that I do not use the fragmentActivity variable within any Pageradapter method.

1 answer

0


Whoops?

Face the Appcompatactivity extends from Fragmentactivity.

so Android Studio does not point out as error, and your app works normally.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.