Java tutorial
/** * Copyright (C) 2015, Jordon de Hoog * <p/> * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * <p/> * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package ca.hoogit.hooold.Main; import android.content.Context; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import ca.hoogit.hooold.Message.MessageFragment; import ca.hoogit.hooold.R; /** * @author jordon * * Date 11/08/15 * Description * */ public class FragmentAdapter extends FragmentPagerAdapter { private String[] mTitles; public FragmentAdapter(Context context, FragmentManager fragmentManager) { super(fragmentManager); mTitles = context.getResources().getStringArray(R.array.tabs); } @Override public Fragment getItem(int position) { if (position < mTitles.length) { return MessageFragment.newInstance(position); } return null; } @Override public CharSequence getPageTitle(int position) { return mTitles[position]; } @Override public int getCount() { return mTitles.length; } }