Taishi-Y
12/22/2017 - 2:59 AM

TypicalViewPagerAdapterTemplate

TypicalViewPagerAdapterTemplate

import android.content.Context
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
/**
 * Created by taishi-y on 2017/12/20
 */

class ${NAME}(fm: FragmentManager, val context: Context) : FragmentPagerAdapter(fm) {

    override fun getItem(position: Int): Fragment = when(position) {
        0 -> ExampleFragment.newInstance()
        1 -> ExampleFragment.newInstance()
        else -> throw IllegalArgumentException("fragment not found")
    }

    override fun getPageTitle(position: Int): CharSequence = when(position) {
        0 -> context.resources.getString(R.string.example_title)
        1 -> context.resources.getString(R.string.example_title)
        else -> throw IllegalArgumentException("title not found")
    }

    override fun getCount(): Int = 2
}