package jackall.moncalc.adapter import android.content.Context import android.support.v4.app.Fragment import android.support.v4.app.FragmentManager import android.support.v4.app.FragmentPagerAdapter import jackall.moncalc.R import jackall.moncalc.fragment.FruitAnalyze import jackall.moncalc.fragment.HistoryFragment import jackall.moncalc.fragment.TempleAnalyze /** * Created by matsumoto_k on 2017/11/03. */ class MainFragmentPagerAdapter(fragmentManager: FragmentManager, val context: Context) : FragmentPagerAdapter(fragmentManager) { val pageCount = 3 val titles = arrayOf(context.resources.getString(R.string.history), context.resources.getString(R.string.temple_analyze), context.resources.getString(R.string.fruit_analyze)) override fun getItem(position: Int): Fragment? { when (position) { 0 -> return HistoryFragment() 1 -> return TempleAnalyze() 2 -> return FruitAnalyze() } return null } override fun getCount(): Int { return pageCount } override fun getPageTitle(position: Int): CharSequence { return titles.get(position) } }