Tabs and ViewPager (Android Development Patterns Ep 9)
Why Stack Overflow recommends it
Stack Overflow users link it as the canonical walkthrough for implementing tabs with ViewPager and TabLayout, especially when older ActionBar tab navigation is deprecated.
Recommended by 2 people across 3 different months, 2014 to 2019.
What it is
A short episode of Google's Android Development Patterns series showing how to combine ViewPager, PagerAdapter and TabLayout from the Android Design Support Library to build swipeable tabbed screens. It is presented on the official Android Developers channel and follows Material Design tab guidelines.
What people said
Recommends ianhanniballake · 2014-06 · Stack Overflow · on “Action bar navigation modes are deprecated in Android L”
The new Android Design Support Library [LINK] adds TabLayout [LINK] , providing a tab implementation that matches the material design guidelines for tabs [LINK] . A complete walkthrough of how to implement Tabs and ViewPager can be found in this video [this video] Now deprecated: The PagerTabStrip [LINK] is part of the support library (and has been for some time) and serves as a direct replacement. If you prefer the newer Google Play style tabs, you can use the PagerSlidingTabStrip library [LINK] or modify either of the Google provided examples SlidingTabsBasic [LINK] or SlidingTabsColors [LINK] as explained in this Dev Bytes video [LINK] .
Recommends ianhanniballake · 2016-07 · Stack Overflow · on “Android - What is the standard way to implement the tab now?”
The Android Design Support Library [LINK] adds TabLayout [LINK] , providing a tab implementation that matches the material design guidelines for tabs [LINK] . A complete walkthrough of how to implement Tabs and ViewPager can be found in this video [this video] .
Recommends Carl · 2019-02 · Stack Overflow · on “Actionbar.removealltabs() leaving behind the tabs space”
I fixed it by using another way to use tabs, the Tablayout as described in this video. [this video] . I had to make my own Toolbar instead of the default theme one. I have no idea why Android is suggesting a deprecated and buggy way to implement tabs on their official website instead of this. In fact, the TabLayout examples provided in the Youtube video are all 404 not found.
Cites starkshang · 2016-01 · Stack Overflow · on “Can not resolve method getSupportFragmentManager()”
You'd better extends `AppCompatActivity`,this will make some methods like `addTab` compiles failed,because these method belongs to `TabActivity`,to fix these,you can custom your bottom tabbar and set a fragment for one tab by yourself,accroding your ui design,maybe you can use `TabLayout` and `FragmentManager` to make it.there is a video you can refer: [this video]
Cites ianhanniballake · 2016-02 · Stack Overflow · on “Activity with Tabs without using Support Library?”
As mentioned in this answer about features unique to the support library [LINK] , ViewPager [LINK] (what enables swiping between tabs) is only found in the Support Library. In addition, as mentioned in the Tabs and ViewPager guide [this video] , tabs that match the material design specs [LINK] are only found in TabLayout [LINK] , part of the Android Design Support Library [LINK] , which in turn requires Support v4.
Cites Rockstar5645 · 2016-03 · Stack Overflow · on “Errors when trying to implement Swipe Views in android”
Sorry for the code dump, I'm new to android and don't know where the problem is. I'm trying to implement swipe views in my android app and I'm having some trouble. I tried following this tutorial [LINK] and this video [this video] but I'm getting some errors. I want the tabbed interface in my MainActivity Here is my MainActivity.java package com.loomius.loomius; import android.os.Bundle; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class MainActi
Cites Lukasz · 2016-03 · Stack Overflow · on “Where to instantiate the ViewPager - resource not found exception”
I'm following this [this video] instruction video from the google android developers channel to create a simple app with tabs. Unfortunately when putting the code: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewPager viewPager = (ViewPager) findViewById(R.id.content_pager); PagerAdapter pagerAdapter = new ContentPager(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.content_tabs); tabLayout.setupWithViewPager(viewPager); ... into my MainActivitys onCreate I get the exception message: java.lang.RuntimeException: Unable to start activit
Cites sunadorer · 2019-03 · Stack Overflow · on “Android Jetpack Navigation with ViewPager and TabLayout”
Experimented with different approaches to handle TabLayout with Jetpack Navigation . But hit issues like having a full history of switching between tabs multiple times etc. Browsing known Google Android Issues before raising a request for a demo, I found this existing issue [LINK] . Its status is Closed marked as Intended Behavior with the following explanation: Navigation focuses on elements that affect the back stack and tabs do not affect the back stack - you should continue to manage tabs with a ViewPager and TabLayout - Referring to [this video] .
Cites kaushalyap · 2019-09 · Stack Overflow · on “Androidx - How to handle Nested Graph's fragments from parent fragment using Navigation?”
Quoting Ian Lake's answer [LINK] As per this issue [LINK] : Navigation focuses on elements that affect the back stack and tabs do not affect the back stack - you should continue to manage tabs with a ViewPager and TabLayout [this video] So you have to use ViewPager with tablayout not a nested navigation graph. Please look at tablayout branch [LINK] for a working example.