How to create a custom view extending from viewpager2?

∥☆過路亽.° 提交于 2020-06-23 11:42:24

问题


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

Cannot inherit from final 'androidx.viewpager2.widget.ViewPager2'

Is there a better way to extend from a Viewpager2 so that I could add cusotm functionality?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/59172451/how-to-create-a-custom-view-extending-from-viewpager2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!