How to create a custom view extending from viewpager2?

后端 未结 3 743
清歌不尽
清歌不尽 2021-01-14 12:42

I would like to create my own version of custom ViewPager2 view from extending from the original Viewpager2, but just had a hard time doing it. I get errors such as

相关标签:
3条回答
  • 2021-01-14 13:18

    you can not extends ViewPager2, because it's final class as mentioned in link

    https://developer.android.com/reference/androidx/viewpager2/widget/ViewPager2

    0 讨论(0)
  • 2021-01-14 13:20

    It's clear from the message that it's a final call so you can't inherit from it. However if you care using Kotlin you can use extensions to get some composition going but I am not sure what you want to do here.

    0 讨论(0)
  • 2021-01-14 13:21

    If you want to extend it just because you need Not-Swipeable behaviour, you dont need to do it. ViewPager2 provides nice property called : isUserInputEnabled

    0 讨论(0)
提交回复
热议问题