Skip to content

Commit

Permalink
Use FragmentStatePagerAdapter instead of FragmentPagerAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshixin committed Sep 6, 2016
1 parent 42a59ff commit 95eb1d3
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.chenshixin.bottomnavigation

import android.content.Context
import android.support.design.widget.CoordinatorLayout
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.app.FragmentStatePagerAdapter
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down Expand Up @@ -46,10 +46,8 @@ class BottomNavigation(context: Context?, attrs: AttributeSet?) : CoordinatorLay
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}

fun setFragmentPagerAdapter(fragmentPagerAdapter: FragmentPagerAdapter) {
fun setFragmentPagerAdapter(fragmentPagerAdapter: FragmentStatePagerAdapter) {
bottom_navigation_view_pager.adapter = fragmentPagerAdapter
//Cache all pages
bottom_navigation_view_pager.offscreenPageLimit = fragmentPagerAdapter.count - 1
}

fun setTabItems(tabs: List<BottomNavigationItem>) {
Expand Down

0 comments on commit 95eb1d3

Please sign in to comment.