Adding FragmentTabHost from inside a Fragment created by an activity with NavigationDrawer
<h2>What I have been Trying to Do</h2>

<p>What I have been aiming to do for several days is, using an <code>Activity</code> that <code>implements</code> <code>NavigationView.OnNavigationItemSelectedListener</code>. I want this to create two Tabs inside a <code>android.support.v4.app.Fragment</code> in the <code>FrameLayout</code> provided by the template for the Navigation Drawer on Android Studio 1.5.1. <br>
 - My Current Activity uses a toolbar not an ActionBar. <br>
 - I was hoping to use a <code>ViewPager</code>; hence needing to use Support <code>Fragments</code>.<br>
 - I have followed several code examples online and have looked at <a href="http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html" rel="nofollow noreferrer">Android Developers Reference</a>.
<br> <br></p>

<h2><strong>Other Linked Posts:</strong></h2>

<p><a href="https://stackoverflow.com/questions/19856941/unable-to-add-tabs-inside-fragment-of-navigation-drawer-android">Unable to add Tabs inside Fragment of Navigation Drawer Android</a> | <em>This uses Fragments and the ActionBar</em></p>

<p><a href="https://stackoverflow.com/questions/8688307/android-tabhost-inside-fragment">Android TabHost inside Fragment</a> | <a href="https://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/" rel="nofollow noreferrer"><em>Chosen Answer -> using FragmentActivity</em></a> | <em>Unfortunatly uses a new FragmentActivity but I need to keep my NavigationDrawer so am using one activity</em> </p>

<p><a href="https://stackoverflow.com/questions/20846305/android-tabhost-only-inside-one-fragment-navigationdrawer/20847222#comment58544839_20847222">Android TabHost only inside one Fragment (NavigationDrawer)</a> | <em>This didnt really provide me much help as I am very new to using tabs</em></p>

<p><a href="https://stackoverflow.com/questions/21364568/android-adding-tab-inside-fragment/21364674#21364674">Android Adding Tab inside Fragment</a> | <a href="https://maxalley.wordpress.com/2013/05/18/android-creating-a-tab-layout-with-fragmenttabhost-and-fragments/" rel="nofollow noreferrer"><em>Chosen Answer -> using FragmentTabHost</em></a> | <em>I have taken <code>FragmentTabHost</code> XML and Java code from this example but It has not worked</em></p>

<p><a href="https://stackoverflow.com/questions/27094494/tabs-in-a-class-that-extends-fragment">Tabs in a class that extends fragment</a> | <em>The andswer refers to googles documentation which is not working for me.</em></p>

<p><a href="https://stackoverflow.com/questions/20469877/adding-tab-inside-fragment-in-android">Adding Tab inside Fragment In Android?</a> | <em>Uses <code>android.app.Fragment</code> and the suggested answer didnt work.</em></p>

<p><a href="https://stackoverflow.com/questions/31641979/using-tablayout-inside-a-fragment-tab-text-invisible">Using TabLayout inside a Fragment; tab text invisible</a> | <em>I am using  Design Library <code>v23.1.1</code> | Bugs reported in <code>v22.2.1</code>. The code here gave me no tabs either</em></p>

<p><br>
<strong>Any Suggestion would be appreciated.</strong>
<br>
<br></p>

<h2><strong>MY CODE</strong></h2>

<p><strong><em>NavActivity Class</em></strong> <br></p>

<pre><code>import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;


public class NavigationMenuActivity extends AppCompatActivity
    implements NavigationView.OnNavigationItemSelectedListener {

    Toolbar toolbar;
    DrawerLayout drawerLayout;
    ActionBarDrawerToggle toggle;
    NavigationView navigationView;
    FragmentManager fragmentManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.navmenu_act);

    //Setting up the Toolbar
    toolbar = (Toolbar) findViewById(R.id.navmenu_appbar_tbar);
    setSupportActionBar(toolbar);

    //Set up the action bar toggle
    drawerLayout = (DrawerLayout) findViewById(R.id.navmenu_act_drawerlay);
    toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawerLayout.setDrawerListener(toggle);
    toggle.syncState();

    //Set up the navigation View
    navigationView = (NavigationView) findViewById(R.id.navmenu_nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    //SET THE FRAGMENT
    fragmentManager = getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentById(R.id.navmenu_appbar_fl);

    if(fragment==null) { //If no fragment exists relate the fragment
        fragment = new TabLayoutFragmentExample();
        fragmentManager.beginTransaction()
                .add(R.id.navmenu_appbar_fl, fragment)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
                .commit();
    }
}

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.navmenu_act_drawerlay);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}



@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    if (id == R.id.nav_profile) {
        fragmentManager = getSupportFragmentManager();
        Fragment fragment = fragmentManager.findFragmentById(R.id.navmenu_appbar_fl);
        if(fragment!=null) { //If a fragment exists replace the fragment
            fragment = new TestFragmentNoTabs();
            fragmentManager.beginTransaction()
                    .replace(R.id.navmenu_appbar_fl, fragment)
                    .commit();
        }
    } else if (id == R.id.nav_near_me) {
        // Handle the near me action here

    } else if (id == R.id.nav_proximity) {
        // Handle the proximity action
        fragmentManager = getSupportFragmentManager();
        Fragment fragment = fragmentManager.findFragmentById(R.id.navmenu_appbar_fl);
        if(fragment!=null) {//If A fragment exists replace the fragment
            fragment = new TestFragmentNoTabsTWO();
            fragmentManager.beginTransaction()
                    .replace(R.id.navmenu_appbar_fl, fragment)
                    .commit();
        }
    }
    //Close the drawerLayout after it is clicked?
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.navmenu_act_drawerlay);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    //sync the toggle
    toggle.syncState();
}
}
</code></pre>

<p><strong><em>navmenu_appbar.xml</em></strong> <br></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.design.widget.CoordinatorLayout 
    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"
    android:fitsSystemWindows="true"
    tools:context=".NavigationMenuActivity"&gt;

    &lt;android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"&gt;

        &lt;android.support.v7.widget.Toolbar
            android:id="@+id/navmenu_appbar_tbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/JethrosTheme.PopupOverlay" /&gt;
    &lt;/android.support.design.widget.AppBarLayout&gt;

    &lt;FrameLayout
        android:id="@+id/navmenu_appbar_fl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"&gt;&lt;/FrameLayout&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p><strong><em>TablayoutFragmentExample Class</em></strong> <br></p>

<pre><code>import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;


public class TabLayoutFragmentExample extends Fragment {


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View inflatedView = inflater.inflate(R.layout.tab_layout_frag, container, false);

    TabLayout tabLayout = (TabLayout) inflatedView.findViewById(R.id.tab_layout_frag_tl);
    tabLayout.addTab(tabLayout.newTab().setText("Tab1"));
    tabLayout.addTab(tabLayout.newTab().setText("Tab2"));
    final ViewPager viewPager = (ViewPager) inflatedView.findViewById(R.id.tab_layout_frag_vp);

    viewPager.setAdapter(new PagerAdapter //ChildFragManager; Tnx @Luksprog
            (getChildFragmentManager(), tabLayout.getTabCount())); 

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

    tabLayout.setupWithViewPager(viewPager); //Set Viewpager; Tnx @Luksprog

    return inflatedView;
}

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:
                TestFragmentNoTabs tab1 = new TestFragmentNoTabs();
                return tab1;
            case 1:
                TestFragmentNoTabsTWO tab2 = new TestFragmentNoTabsTWO();
                return tab2;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return mNumOfTabs;
    }
}
}
</code></pre>

<p><strong><em>tab_layout_frag.xml</em></strong> <br></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.design.widget.AppBarLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

    &lt;android.support.design.widget.TabLayout
        android:id="@+id/tab_layout_frag_tl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed"
        app:tabGravity="fill"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/&gt;

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/tab_layout_frag_vp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/white"/&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;
</code></pre>

<p><strong><em>TestFragmentNoTabs &amp; TestFragmentNoTabsTWO (Fragment 1 and fragment 2)</em></strong> <br></p>

<pre><code>import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

public class TestFragmentNoTabs extends Fragment {
    public final String TAG = "TestFragmentNoTabs";

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        //Inflate the fragment view
        View view = inflater.inflate(R.layout.testfragnotabs, container, false);
        return view; //Return the view to the activity
    }

    @Override
    public void onPause() {
        super.onPause();
    }
}
</code></pre>

<p><strong><em>testfragnotabs.xml</em></strong> (similar to testfragnotabstwo.xml)  <br></p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/nearme_frag_rlay"
    android:clickable="false"&gt;

    &lt;TextView
        android:id="@+id/nearme_frag_tv_seclab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text=" TestFragmentNoTabsOne -&gt; testfragnotabs.xml" /&gt;

    &lt;TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:id="@+id/textView1"
        android:layout_above="@+id/nearme_frag_tv_seclab" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<h2>Current Situation with Above Code</h2>

<p>The project builds fine and the navigation drawer is working fine as well. However the frame layout where the fragment and the TabLayout should appear is empty with a white background (Just like the Design preview in tab_layout_frag.xml; this could mean there is a problem with the ViewPager or the TabLayout?).</p>