Android Tabs Example - With Fragments and ViewPager - Truiton
Skip to content

Android Tabs Example – With Fragments and ViewPager

Android Tab Example

One of the best things about technology is that it keeps on changing. On the same lines recently some significant improvements were made for Android by the means of support library. The new Design Support Library was included in the support repository. This new Android Design Support library features many new UI components like snackbars, floating action buttons and of-course it significantly improves the implementation of Android Tabs. Since Android design support library contains many new UI widgets which were introduced as concepts with material design. I would write separate tutorials for each one of those. Here lets concentrate on the Android tabs example.

Earlier to make tabs in Android, action bar was used. But now with API 21 onwards it has been deprecated. An alternative way to make tabs with full backward support was to use SlidingTabLayout and SlidingTabStrip classes. But now with Android Design Support Library making swipe tabs has become even more simpler. In this Android Tabs example lets explore the power of new design support library.

Making an Android Tabs Example by using Android Design Support Library

Tab type navigation mode is a very common design pattern among android apps. But since Android’s 5.0 release, material design came in to picture and allot of changes were made in various APIs. Resulting the deprecation of action bar. Although a new API, Android Toolbar was released to replace it. Due to this change, new APIs for android tabs were also released through the design support library recently. The main class used for displaying tabs through these new APIs is Android TabLayout. In this Android Tab example we would make a screen with three tabs using these new APIs for tabs with Fragments and a ViewPager which would look like the image below:

Android Tabs Example

To start off please include these libraries in the dependencies section of your build.gradle file:

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'

Now since we will be using Android Toolbar and TabLayout classes to show tabs, lets remove the action bar from layout by using styles:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!--   your app branding color for the app bar -->
        <item name="colorPrimary">#3F51B5</item>
        <!--   darker variant for the status bar and contextual app bars -->
        <item name="colorPrimaryDark">#303F9F</item>
        <!--   theme UI controls like checkboxes and text fields -->
        <item name="colorAccent">#FF4081</item>
    </style>

</resources>

To get a better understanding on Android Toolbar and its usage have a look at this Android Toolbar tutorial.

Next, to display Android tabs with fragment and ViewPager, lets define three simple fragments and their layouts:

package com.truiton.designsupporttabs;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class TabFragment1 extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.tab_fragment_1, container, false);
    }
}

Its layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Tab 1"
        android:textAppearance="?android:attr/textAppearanceLarge"/>

</RelativeLayout>

Android Tab 2:

package com.truiton.designsupporttabs;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class TabFragment2 extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.tab_fragment_2, container, false);
    }
}

Its layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Tab 2"
        android:textAppearance="?android:attr/textAppearanceLarge"/>

</RelativeLayout>

Android Tab 3:

package com.truiton.designsupporttabs;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class TabFragment3 extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.tab_fragment_3, container, false);
    }
}

Its layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Tab 3"
        android:textAppearance="?android:attr/textAppearanceLarge"/>

</RelativeLayout>

Now that we have all the tab fragments defined, lets define a view pager adapter for the swipe tabs feature:

package com.truiton.designsupporttabs;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class PagerAdapter extends FragmentStatePagerAdapter {
    int mNumOfTabs;

    public PagerAdapter(FragmentManager fm, int NumOfTabs) {
        super(fm);
        this.mNumOfTabs = NumOfTabs;
    }

    @Override
    public Fragment getItem(int position) {

        switch (position) {
            case 0:
                TabFragment1 tab1 = new TabFragment1();
                return tab1;
            case 1:
                TabFragment2 tab2 = new TabFragment2();
                return tab2;
            case 2:
                TabFragment3 tab3 = new TabFragment3();
                return tab3;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return mNumOfTabs;
    }
}

In the view state pager adapter above, you may see that I have just initialized the fragments as per their location. Next lets define the layout for main activity where all these tabs would be displayed.

Displaying Tabs using Android TabLayout

<RelativeLayout
    android:id="@+id/main_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="?attr/colorPrimary"
        android:elevation="6dp"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:background="?attr/colorPrimary"
        android:elevation="6dp"
        android:minHeight="?attr/actionBarSize"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/tab_layout"/>

</RelativeLayout>

Earlier tabs were added to the action bar through code. But as you can see in this Android tabs example layout above we are using Toolbar and the TabLayout separately to display tabs. Also please note a view pager is also added, which would be attached to this TabLayout in the activity below through code.

package com.truiton.designsupporttabs;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));
        tabLayout.addTab(tabLayout.newTab().setText("Tab 3"));
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

        final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
        final PagerAdapter adapter = new PagerAdapter
                (getSupportFragmentManager(), tabLayout.getTabCount());
        viewPager.setAdapter(adapter);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
        tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewPager.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

The above class concludes this Android tab example with Fragments and ViewPager. As you can see that, above we have used the Android Toolbar instead of action bar and tabs are further added in the TabLayout through code with text. Then you can see that ViewPager is attached with an adapter using the ViewPager.setAdapter(adapter) method. Next Android ViewPager is attached to a page change listener of TabLayout by using the method ViewPager.addOnPageChangeListener. Further the Android TabLayout is attached to a tab selected listener using the TabLayout.setOnTabSelectedListener method, in which ViewPager’s page is set when a tab is selected. This whole piece of code would make an Android Tab example which would run on Android 7+ APIs. Hope this helps. Connect with us on Facebook, Google+ and Twitter for more updates.

163 thoughts on “Android Tabs Example – With Fragments and ViewPager”

  1. Hi. Brilliant and clean/simple tutorial πŸ™‚ How can I use strings for the names of my tabs rather than hard-coding them?

  2. compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:design:22.2.0'
    Getting This below Error how to solve it
    Failed to find compile ‘com.android.support:design:22.2.0’

    1. Check Your TargetSDK Version in module(app.gradle)
      …according to that put 22,23,24
      example your target sdk is 24 than put
      compile ‘com.android.support:appcompat-v7:24.0.0’
      compile ‘com.android.support:design:24.0.0’

      1. You need to change
        compile ‘com.android.support:appcompat-v7:22.0.0’
        compile ‘com.android.support:design:22.2.0’

        to

        compile ‘com.android.support:appcompat-v7:28.0.0’
        implementation ‘com.android.support:design:28.0.0’

        this showed no error to me

  3. Hi. Any direction on how to implement this tab layout in one of the navigation view item clicked. Do I just put the code from MainActivity in to the item’s fragment class?

  4. Hey, Thanks for the tutorial.
    I have one query. How can I change the Font size of Tabs, because my Tab’s text are quite big so they not set in single line.(Or is it possible to swap Tabs if in case I don’t want to font size).

  5. Hey, Thanks for example. I’m having one issue, when I swipe on ViewPager is working perfect but when I swipe from from left to right or right to left and select previous Tab: Tab indicator appear on new selected Tab but respective fragment not appear on ViewPager.
    Please help me, where I’m getting wrong?

  6. Very nice! Thank you.
    If I want to insert a new ListView in Tab #1, where do I place the JAVA code of the ListView?
    It doese’t make sense at TabFragment1.java

  7. Thank you for the tutorial. It works great. But I’m having a problem when changing orientation. I removed android:orientation="vertical" but still stopping the application. What could be wrong?

  8. I want load only the selected tab to be loaded i don’t want to load the adjacent tab into the memory how can i do this. If click on the selected again it should get refresh every time i select to the tab

  9. Hi! Great tutorial, I’m a beginner in android and thanks to you I’ve understand many things.
    I need to add a listview in one of the tabfragments, but I can’t find the right way, can you help me?
    Thanks a lot!

      1. hey thanks a lot ,
        was really helpfull~~
        u make a nice tutor!!
        you should start a video tutorial series~~~~~
        bst of luck myaaaan…..

  10. Hello,
    First of all, Thank you for this great tutorial.
    i have a small question :
    Let’s say i have a new Fragment “SecondFragmentInTab1” , and i want to open it in the Tab 1 after clicking some button in the fragment TabFragment1 .
    How can i do this ?

    Thank you,
    Houcine

  11. Nice tutorial !!
    How can I switch tabs programmatically? eg : If Tab 1 has a list of items on click of which I want to display the details of that item in Tab 2..

  12. Great tutorial, everythings works fine, even if i’m using images instead of text.
    But, right now, I want that when a tab is selected, the image of the selected tab change (to show the user where he is changing color of the selected tab).
    I have really no idea of how I can do this, may be a :
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    @Override
    public void onPageSelected(int position) {
    actionBar.setSelectedNavigationItem(position);
    }
    would made the thing working

  13. Thank you for your easily, standard and neat code for Android Tabs.I hope you will make more android code for us further.Thanks once again.

  14. Thanks man! I’m currently studying Murachs Android programming which is quite outdated. Thanks to this I’ve managed to make a task list with TabLayout including savedInstanceState.

  15. Hi, It’s great. I’m an amateur programer. Please answer.
    If I put button on tab 1, where i should put on click listener? Mainactivity.java, or TabFragment1.java, or else?

  16. Ebates an app i want you to see..and please tell me how that feautred design is made…while scolling up in featured option in navigation drawer images view hides and tab come below action bar of navigation drawer….it will be very thankfull if you reply πŸ™‚

  17. Hi,

    Very neat tutorial.

    I want to include tabLayout in one of the fragments of my slide menu.
    My slide menu is working fine as seperate. But how can I combine both of these for one of the fragments in my menu.

    Thanks in advance for help.

  18. Great tutorial, easy to read and understand !
    Be now we can simplify it a little more πŸ™‚
    Instead of using “viewPager.addOnPageChangeListener” and “tabLayout.setOnTabSelectedListener” we can now directly use “tabLayout.setUpWithViewPager(viewPager);” and it will works just fine !

  19. Hello and thanks for a most excellent tutorial!

    If you could be bothered, would you please explain how would I reference the View inflated by each fragment from the MainActivity? Explaining myself, in my app, each fragment in the TabLayout represents a portion of some class’s data. I want to be able to create an instance of the class in my MainActivity and pass it references to each fragment’s inflated view so that the instance is able to reference each view’s layout components in order to update its value.

    Do I make sense? πŸ™‚

    Thanks again!

  20. Hiii
    Very nice tutorial thanks for knowledge sharing.
    I have a little problem, i.e I want to add 6 tabs and it is working but all tabs are displayed on same screen size i want to have a scrolling effect to tabs section, how can i do it as after giving names to the tabs every tabs shrinks and its bit difficult to read…
    Can you please help me on this.

    Thanks

  21. Hi Mohit!

    Thanks very much for this, it’s brilliant!

    One question, how to enable “white” divider between each tab?

    I have tried this in the tab_layout, but still it does not show a divider, can you help please?

    android:divider=”@android:color/white”
    android:showDividers=”middle”
    android:dividerPadding=”1dp”

    Thanks!
    Matt

  22. Hello sir, I’m following your tutorial and thanks to you I have created my own tab layout but I want my page to be changed not by swiping but clicking only the names of the tabs at the top.
    I’ve done both swiping and clicking the tabs but I only want to change the page when clicking the tab names. Any idea on how should I do that?
    thank you sir.

  23. How do you use each tab afterwords? use as in how do you manipulate each tab as if they were an activity? I can’t figure out how to use the simple setText(“Hello”) method after making the tabs.

  24. This is by far the best example I have found for using tabs and fragments – and I have read a LOT of tutorials!

    Thank you so much!

  25. Hi Mohit .Thanks for the great tutorial.I have one small query.I have one activity and 5 fragments in the sliding tab layout.Can you please tell me what would be the best way to communicate between them.I need to send bundles across .

  26. Thank You Mohit For such amazing tutorial. I have 1 doubt ,If possible then please help me. After user logged in They are redirected to tabs activity(according to above tuts). I want to print users detail in first fragment .But became bit confused how to actually implement it inside fragment Because we have 1 activity inside which there are 3 fragments . Please simply guide me. Thank you in advanced.

  27. Hi. Thanks for sharing this tutorial. I’m getting error on this line:

    final PagerAdapter adapter = new PagerAdapter
    (getSupportFragmentManager(), tabLayout.getTabCount());

    The error states:
    ‘PagerAdapter’ is abstract; cannot be instantiated

    Can you please explain how to solve this?

    1. I believe you may have imported the wrong class i.e. android.support.v4.view.PagerAdapter.

      Instead you need to import the PagerAdapter class defined in the tutorial above.

      -Mohit

  28. I have 4 Tabs, in the 4 Tabs using SlidingTabLayout, I have validation alert in 4 tab onCreateView Mehod if mVar == null {toast} ,

    when i click 3 tab its throwing 4 tab Validation message,

    how to Avoid this.

    Please guide

    1. FragmentStatePagerAdapter always loads the next fragment in memory, that is why your validation message is being triggered.

      Therefore change your logic. Generally its a good practice to trigger validation logic after user performs some action.

      1. Hai…I have 4 fragment in view pager using fragment page adapter…when i select 3rd position tab,calling 0th position tab…i cant understand why this happening,i have api call for every tabs…i need to call api when i select that particular tab….plz help me…

  29. Hello sir. I am beginner in android programming. I found your website very helpful. You r the man of the century. Keep it up.
    I am following this tutorial from beginning and everything is working fine. Could you please tell me how can i add icon+text to tabs? It will be appreciated. Thanks in advance.

  30. Thank you Mohit for the fantastic tutorial! Worked like a charm.
    Reader: You should try this method if you’re having trouble with deprecated classes and functions, and just need a simple Tab control implemented that (seems to be) supported on old API versions. I am using the following libraries in build.gradle with a Minimum compatibility of API 9, and so far so good:

    dependencies {

    compile ‘com.android.support:appcompat-v7:23.2.1’
    compile ‘com.android.support:design:23.2.1’
    compile ‘com.android.support:support-v4:23.2.1’

    }

  31. I am getting “Cannot resolve symbol” error with (R.menu.menu_main, menu) and (R.id.action_settings) in the MainActivity.java file. I’m guessing for the “R.menu.menu” error is due to the fact that I do not have a res/menu.xml file, am I correct in saying this? If so, what value are needed for this file? Help with these two problems would be greatly appreciated. Love your work.

  32. Thanks man, after much searching found a clean/simple tutorial that works. Your explanation of the concepts was excellent, keep up the good work.

  33. How can i for example use a listview filled wit data coming from a database, i can do it on a normal activity but not in the fragment, can you give some tips ? Thanks a lot.

  34. lovely!
    how would you go about using one single view (no more viewpager swiping), and each tab that is selected, loads the data into the same view, replacing what was shown before

  35. Very nice example! How can i do a .addToBackStack(“MY_FRAGMENT”) to capture in my main activity onBackPressed event to do something with “MY_FRAGMENT”?

  36. I am using your example. I am having a hard time trying to adjust the padding for each tab. The padding seems so big that it cuts off the tab labels too much. Setting the padding in XML of programatically seems to do nothing.

  37. Thank you very much man, i’ve been looking for an implementation about this tabs for a weak and none was so easy and clear like yours.

  38. hi i’m new in android programing and a i don’t speak english very well so sorry if you notice wrong word in my comment
    well i have a problem using your tutorial.
    when i switch to the tab1 for example i got sometime the fragment 2 or fragment 3 and same for the other tabs would somebody help me please

  39. Do I need the Toolbar? I tried removing in activity_main.xml and it works fine. I was thinking of making an app where there is a small “hamburger” button on left instead of using a toolbar. Of course, I need a button or something (smaller toolbar perhaps) for the menu button with that approach.

  40. I am creating an Android Reminder App. So, I have a Navigation Drawer. Now, Consider, I have 3 Categories . My First category consists of 3 tabs, 2nd category consists of 4 tabs, and 3rd category consists of 2 tabs . So, I have 3 Activities to host all the tab fragments in them. I don’t want any independent fragment to open. I want to click on Navigation drawer item and go to particular tab on tab layout.

    Now , when I start it opens fragment one of first Activity .(very good). Then , I can go to fragment2 and fragment3 . But, If I click on Fragment 4, Fragment 5, Fragment 5 then it remains in Fragment3, coz they are in different activity. So, I need to open that activity and then I am able to go to Fragment 4, Fragment5, Fragment 6 and then again I click on Frament 1, 2 or 3 . It remains in the last opened fragment .

  41. It was very helpful to me. I add in the first tab an alert dialog. I want to passing to second tab when user click on yes button on the alert dialog. I couldn’t make it. I couldn’t access the pager in main activity.

  42. Hi thanks for great tutorial its very clear and i have question i created a button in side tabs and here is my question up on clicking that button i wanted to open a new activity i request you to help me in this please thanks in advance have a great day.

  43. Hi,

    Thanks. The example works just fine!!

    Is it possible to define the tablayout to show inside just one fragment and it works exactly the same way ?

  44. I want to use more than 3 tabs and the tabs must be scrollable,,when i initialize more than 3,it gets all compressed and shown in a single page view….i want the tabs to be scrollable…What should i do??can u help me plz

  45. Hey Mohit, just wanna thank you for an awesome tutorial!
    Messing around with my first app right now, and this helped me out a lot!

  46. Hi , Than you for amazing tutorial, But what if in Frag3 a button and when I click on it, will replace Frag3 with a new frag4
    How to implemnt that please

  47. Very elegant implementation of tabs, Mohit. However, I wasn’t able to build the project. In MainActivity.java, the line

    final PagerAdapter adapter = new PagerAdapter (getSupportFragmentManager(), tabLayout.getTabCount());

    is being flagged with an error: ‘PagerAdapter’ is abstract; cannot be instantiated. I’m building with Android Studio, 2.3.3. Thanks for your help. I’m eager to fold your code into my project.

    1. Hi,

      Thanks.
      But I believe you may have imported the wrong class i.e. android.support.v4.view.PagerAdapter.
      Instead you need to import the PagerAdapter class defined in the tutorial above.

      -Mohit

  48. Thank you for nice tutorial brother. I want to apply 3 tabs in the fragment how can I do that. I have 6 fragments and every fragment have three tabs can you help me how can I do that? I am confused because your are using tabs in activity but how can it be handle inside fragment

  49. simply super sir. Sir I want the this tabbed activity after the login page. I tried a lot. The login data credentials are stored into the firebase when clicked on the login button but it doesn’t navigate to tabbed activity. It shows app is unfortunately stopped. Can u please help me out sir.

  50. Hi Mohit,
    Thanks a lot for this useful tutorial. I am new to Android and I need one help with this tutorial.
    I have implemented this code and it works fine. But I am facing a issue or blockage due to lack of knowledge here.
    I have created 5 tabs and in each tabs I will show some data as list which will be fetched via REST API made by me. Now I know how to fetch but I dont know how show it like facebook or other apps as feed.

    For 5 tabs I have created 5 classes extending Fragment. Do I need to write in each Class onCreateView method? Please help me as I am stuck and not getting any useful info. I tried a lot for 3 days but in vain.

    Regards,
    Chayan

  51. Hey Mohit, Great work…

    Can you please help, im using your code, with 6 tabs, an the problem i am facing is that, most of the times, there is a mismatch between the tab selected, and the corresponding viewpager…

    any idea

  52. Hi. I have a problem with this Tab system. The problem is how to change the text dynamically from MainActivity of tab1, tab2 or tab3,
    I’m using inflater but no changes occurred due to program running.For example this code do not change the text into “JUST WE CAN”
    View view = inflater.inflate(R.layout.coordinators_tab, container, false);
    TextView txt = view.findViewById(R.id.textView4);
    txt.setText(“JUST WE CAN”);

  53. Nice Tutorial dude,
    anyway I created 3 bottom navigation with fragments.i want to add your tute into one of my bottom tab.It means I want to add 3 tabs into one of my bottom tab.How to add 3 tabs into bottom navigation…please answer and any tutorial link please…

  54. Mohit, I’m in grad school in a Mobile App Development course, and your help here was indispensible. Thank you, thank you, thank you. I was able to understand the structure of what you were doing, and apply that to my own design. Thanks for the crash course!

Leave a Reply

Your email address will not be published. Required fields are marked *