1

How can I disable switching between tabs when user presses on them?

I use ViewPager and then polute it with tabs. I managed to disable swiping by using following code, but this doesn't prevent user from switching between tabs by clicking on them:

@Override
public boolean onTouchEvent(MotionEvent event) {
    return false;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    return false;
}
Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
Mislice Igra
  • 21
  • 1
  • 5
  • Possible duplicate of [how to disable a tab in android screen?](http://stackoverflow.com/questions/4497187/how-to-disable-a-tab-in-android-screen) – Elshan Aug 14 '16 at 08:03

1 Answers1

2

If you are using the latest 'android.support.design.widget.TabLayout' then check this link TabLayout

or if you using the old TabHost method then check this link TabHost

Community
  • 1
  • 1
darwin
  • 1,524
  • 1
  • 22
  • 32