diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java index b0db9cd1..930d0c67 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/CommonTabLayout.java @@ -14,6 +14,7 @@ import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; +import android.support.v4.app.FragmentManager; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; @@ -202,8 +203,8 @@ public void setTabData(ArrayList tabEntitys) { } /** 关联数据支持同时切换fragments */ - public void setTabData(ArrayList tabEntitys, FragmentActivity fa, int containerViewId, ArrayList fragments) { - mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments); + public void setTabData(ArrayList tabEntitys, FragmentManager manager, int containerViewId, ArrayList fragments) { + mFragmentChangeManager = new FragmentChangeManager(manager, containerViewId, fragments); setTabData(tabEntitys); } diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java index e9df2953..83679175 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SegmentTabLayout.java @@ -13,6 +13,7 @@ import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; +import android.support.v4.app.FragmentManager; import android.util.AttributeSet; import android.util.SparseArray; import android.util.TypedValue; @@ -171,8 +172,8 @@ public void setTabData(String[] titles) { } /** 关联数据支持同时切换fragments */ - public void setTabData(String[] titles, FragmentActivity fa, int containerViewId, ArrayList fragments) { - mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments); + public void setTabData(String[] titles, FragmentManager manager, int containerViewId, ArrayList fragments) { + mFragmentChangeManager = new FragmentChangeManager(manager, containerViewId, fragments); setTabData(titles); } diff --git a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java index 9ab7e5ed..c3dfcf23 100644 --- a/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java +++ b/FlycoTabLayout_Lib/src/main/java/com/flyco/tablayout/SlidingTabLayout.java @@ -205,7 +205,7 @@ public void setViewPager(ViewPager vp, String[] titles) { } /** 关联ViewPager,用于连适配器都不想自己实例化的情况 */ - public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, ArrayList fragments) { + public void setViewPager(ViewPager vp, String[] titles, FragmentManager manager, ArrayList fragments) { if (vp == null) { throw new IllegalStateException("ViewPager can not be NULL !"); } @@ -215,7 +215,7 @@ public void setViewPager(ViewPager vp, String[] titles, FragmentActivity fa, Arr } this.mViewPager = vp; - this.mViewPager.setAdapter(new InnerPagerAdapter(fa.getSupportFragmentManager(), fragments, titles)); + this.mViewPager.setAdapter(new InnerPagerAdapter(manager, fragments, titles)); this.mViewPager.removeOnPageChangeListener(this); this.mViewPager.addOnPageChangeListener(this); diff --git a/app/build.gradle b/app/build.gradle index f2f86d4d..9d16d63e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,10 +22,10 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:25.1.0' -// compile project(':FlycoTabLayout_Lib') + compile project(':FlycoTabLayout_Lib') //--->support 3.0+ - compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' +// compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar' //--->support 2.2+ // compile 'com.flyco.tablayout:FlycoTabLayout_Lib:2.0.0@aar' // compile 'com.nineoldandroids:library:2.4.0' diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java index b898c2ce..4b137b94 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/CommonTabActivity.java @@ -83,7 +83,7 @@ protected void onCreate(Bundle savedInstanceState) { mTabLayout_1.setTabData(mTabEntities); tl_2(); - mTabLayout_3.setTabData(mTabEntities, this, R.id.fl_change, mFragments2); + mTabLayout_3.setTabData(mTabEntities, this.getSupportFragmentManager(), R.id.fl_change, mFragments2); mTabLayout_4.setTabData(mTabEntities); mTabLayout_5.setTabData(mTabEntities); mTabLayout_6.setTabData(mTabEntities); diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java index 9ac154cc..3cddcc61 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SegmentTabActivity.java @@ -51,7 +51,7 @@ protected void onCreate(Bundle savedInstanceState) { tabLayout_1.setTabData(mTitles); tabLayout_2.setTabData(mTitles_2); tl_3(); - tabLayout_4.setTabData(mTitles_2, this, R.id.fl_change, mFragments2); + tabLayout_4.setTabData(mTitles_2, this.getSupportFragmentManager(), R.id.fl_change, mFragments2); tabLayout_5.setTabData(mTitles_3); //显示未读红点 diff --git a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java index 290c9b03..81383709 100644 --- a/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java +++ b/app/src/main/java/com/flyco/tablayoutsamples/ui/SlidingTabActivity.java @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) { tabLayout_5.setViewPager(vp); tabLayout_6.setViewPager(vp); tabLayout_7.setViewPager(vp, mTitles); - tabLayout_8.setViewPager(vp, mTitles, this, mFragments); + tabLayout_8.setViewPager(vp, mTitles, this.getSupportFragmentManager(), mFragments); tabLayout_9.setViewPager(vp); tabLayout_10.setViewPager(vp);