package com.beck.matthew.customtabs;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Arrays;

public class TabPagerAdapter extends PagerAdapter {

    private Context mContext;
    ViewGroup[] layouts;

    public TabPagerAdapter(Context context) {
        mContext = context;
        layouts = new ViewGroup[PagerEnum.length()];
        Arrays.fill(layouts, null);
    }

    public Object instantiateItem(ViewGroup collection, int position) {
        PagerEnum pagerEnum = PagerEnum.values()[position];
        LayoutInflater inflater = LayoutInflater.from(mContext);
        ViewGroup layout;
        if (layouts[position] != null) {
            layout = layouts[position];// Here its just set to the previouse layout that was inflated
        } else {
            layout = (ViewGroup) inflater.inflate(pagerEnum.getLayoutResId(), collection, false);// inflates the layout
            layouts[position] = layout;// saves the layout in the array
            /*
            Here place any ListView adapters and initalize them.
			This is because of some bugs. Adapters that are updated in another class will have to have a static adapter
			*/
        }
        collection.addView(layout);
        return layout;
    }

    @Override
    public void destroyItem(ViewGroup collection, int position, Object view) {
        collection.removeView((View) view);
    }

    @Override
    public int getCount() {
        return PagerEnum.values().length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        PagerEnum pagerEnum = PagerEnum.values()[position];
        return pagerEnum.getTitle();
    }
}
@@ -1,8 +1,569 @@
+/**%0ACopyright 2016 mattwolf1234%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A**/%0A
 package 
@@ -2438,8 +2438,9 @@
 %0A    %7D%0A%7D
+%0A

Update TabPagerAdapter.java