Sliding tabs using ViewPager in Android Studio

Pro Grammer · 156K views · 2017 · 9:32

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the baseline example for sliding tabs, both as a starting point for their own code and as a reference when asking why their adapted version misbehaves.

Recommended by 1 people across 1 different months, 2018 to 2019.

What it is

A short Android Studio tutorial that builds swipeable tabs using ViewPager, TabLayout and fragments. The presenter walks through the code, with the source on GitHub and a matching Medium article.

What people said

Recommends Vipul Chauhan · 2019-06 · Stack Overflow · on “How to add toggle button to the right toolbar?”

i think your error is your toggle button is not placed at the right position because you are using action bar theme make your own action bar to correct this and change theme of no action bar.OR see the video [this video] it is a tutorial for viewpager

Cites Rounak Polley · 2018-01 · Stack Overflow · on “Tabs (with fragments) within Fragment”

I created the tabs by following this [this video] but in this tutorial the tabs are within an activity where as I need them within fragments something like nested fragments. And for the fragment I have added the code in onCreateView I'm getting an error while trying to create an instance of TrainSearchFragmentAdapter which is another class that extends FragmentPagerAdapter . This is my main activity which is a nav drawer activity Screenshot of Nav Drawer [LINK] This is the fragment that opens on clicking a nav option Screenshot of the fragment with tabs [LINK] Here is my code for the parent fragment : public class TrainSearchFragment extends Fragment implements TrainSearchTrainByNoFragment.OnFrag

Cites Redas Shuliakas · 2018-03 · Stack Overflow · on “Android Tablayout,why tabs not moving?”

I was following this tutorial [this video] I've used his code from github, but output is wrong. I've put 3 tabs on the top, and when I press on tab, activity supposed to change, but in reality, nothing happens, I still have only my main_activity on the screen. Hope someone will help. Here is my codes PS - Yes I have also 3 xml files for every fragment (even I have also main_activity, but I have to find out what's wrong, and then will asign 1tab with main activity). I have also 3 java files for this 3 tabs. XML <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView xmlns:android=" [LINK] " xmlns:app=" [LINK] " xmlns:tools=" [LINK] " android:layout_width="match_parent" a

Cites pinbu · 2018-11 · Stack Overflow · on “Swipe tabs in dynamic fragment”

I have found the answer for the question, the problem was not setting the params for the viewpager and not giving him an id, and not adding it to the layout. For those who are struglling with the same question, just take the normal swipe tabs code( [this video] ) and keep in mind that you are using a dynamic fragment so you can't declare xml. import android.graphics.Color; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; public class fg