Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implementing swipe between tab using tab-host in Android

In Android can I implement swipe between tabs functionality using tab-host. Is it possible to use this functionality without fragments. When we are targeting older android versions how can we implement this feature. Can someone help me. Thank You!

like image 719
Samantha Withanage Avatar asked Dec 09 '13 06:12

Samantha Withanage


People also ask

How do I use TabLayoutMediator on Android?

Establish the link by creating an instance of this class, make sure the ViewPager2 has an adapter and then call attach() on it. Instantiating a TabLayoutMediator will only create the mediator object, attach() will link the TabLayout and the ViewPager2 together.


2 Answers

The following link should get you started:

http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/

It uses view pager and adds views of each tab int it. On tab change listener it changes the view in view pager.

like image 161
vipul mittal Avatar answered Oct 05 '22 20:10

vipul mittal


If you are going to use Fragments, go by @vipulmittal answer Or else you want to implement touch listener like SimpleGestureListener based on your requirements. Good example is here

like image 40
kumar_android Avatar answered Oct 05 '22 19:10

kumar_android