Google is committed to advancing racial equity for Black communities. See how.

LeanbackViewPager

public class LeanbackViewPager
extends ViewPager

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.viewpager.widget.ViewPager
         ↳ androidx.leanback.tab.LeanbackViewPager


A viewpager with touch and key event handling disabled by default.

Key events handling is disabled by default as with the behaviour of viewpager the fragments can change when DPAD keys are pressed and focus is on the content inside the ViewPager. This is not desirable for a top navigation bar. The fragments should preferably change only when the focused tab changes.

Summary

Inherited constants

Inherited fields

Public constructors

LeanbackViewPager(Context context)

Constructs LeanbackViewPager

LeanbackViewPager(Context context, AttributeSet attrs)

Constructs LeanbackViewPager

Public methods

boolean executeKeyEvent(KeyEvent event)

You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.

boolean onInterceptTouchEvent(MotionEvent event)
boolean onTouchEvent(MotionEvent event)
void setKeyEventsEnabled(boolean enableKeyEvent)

Setter for enabling/disabling key events

void setTouchEnabled(boolean enableTouch)

Setter for enabling/disabling touch events

Inherited methods

Public constructors

LeanbackViewPager

public LeanbackViewPager (Context context)

Constructs LeanbackViewPager

LeanbackViewPager

public LeanbackViewPager (Context context, 
                AttributeSet attrs)

Constructs LeanbackViewPager

Public methods

executeKeyEvent

public boolean executeKeyEvent (KeyEvent event)

You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.

Parameters
event KeyEvent: The key event to execute.

Returns
boolean Return true if the event was handled, else false.

onInterceptTouchEvent

public boolean onInterceptTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

setKeyEventsEnabled

public void setKeyEventsEnabled (boolean enableKeyEvent)

Setter for enabling/disabling key events

setTouchEnabled

public void setTouchEnabled (boolean enableTouch)

Setter for enabling/disabling touch events