I have a ViewPager which instantiates a View. I’d like to disable both the scrolling of the viewpager and the child buttons momentarily while a search result is returned to the view. I’ve calling viewPager.setEnabled(false) but this doesn’t disable it.
Anyone got any ideas?
A simple solution is to create your own subclass of
ViewPagerthat has aprivate booleanflag,isPagingEnabled. Then override theonTouchEventandonInterceptTouchEventmethods. IfisPagingEnabledequals true invoke thesupermethod, otherwisereturn.Then in your
Layout.XMLfile replace any<com.android.support.V4.ViewPager>tags with<com.yourpackage.CustomViewPager>tags.This code was adapted from this blog post.