Created
December 22, 2017 02:59
-
-
Save Taishi-Y/5618ea63c4baa9a37b08bfca157080b0 to your computer and use it in GitHub Desktop.
TypicalViewPagerAdapterTemplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment