Skip to content

Commit

Permalink
修复YzsBaseHomeActivity使用framelayout初始化选中,设置首页缓存数量(依然支持懒加载)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaozs committed Mar 9, 2017
1 parent 40bccf7 commit 61f4e40
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* 16.12.21 新增YzsLoadingDialog,可自定义图片的loading动画
* 16.12.22 新增YzsBaseHomeActivity(首页base父类)
* 17.03.06 优化base方法名,新增demo方便查看
* 17.03.09 修复YzsBaseHomeActivity使用framelayout初始化选中,设置首页缓存数量(依然支持懒加载)

### 本项目使用开源项目
1.[FlycoTabLayout——viewpager指示器 与 导航栏控件](https://github.com/H07000223/FlycoTabLayout)<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void initTab() {
setmIconSelectIds(mIconSelectIds);
setmIconUnSelectIds(mIconUnselectIds);
setmTitles(mTitles);
setInitChooseTab(1);
setInitChooseTab(0);
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/ac_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<!-- 在继承Y轴是BaseHomeActivity是必须声明的id -base_tabLayout
二选一声明base_tabLayout_viewPager或base_tabLayout_frameLayout-->
<android.support.v4.view.ViewPager
android:id="@id/yzs_base_tabLayout_viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="56dp" />
android:id="@id/yzs_base_tabLayout_viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="56dp" />

<!--<FrameLayout-->
<!--android:id="@id/yzs_base_tabLayout_frameLayout"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginBottom="56dp" />-->
<!--android:id="@id/yzs_base_tabLayout_frameLayout"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"-->
<!--android:layout_marginBottom="56dp" />-->


<com.flyco.tablayout.CommonTabLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void initFragments() {
//加载mFragments
if (getBundle() == null) {
//加载mFragments
loadMultipleRootFragment(R.id.yzs_base_tabLayout_frameLayout, 1, mFragments);
loadMultipleRootFragment(R.id.yzs_base_tabLayout_frameLayout, initChooseTab, mFragments);
} else {
// 这里库已经做了Fragment恢复,所有不需要额外的处理了, 不会出现重叠问题
for (int i = 0; i < mFragments.length; i++) {
Expand All @@ -153,6 +153,7 @@ private void initFragments() {
*/
private void initViewpagerAdapter() {
mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
mViewPager.setOffscreenPageLimit(mFragments.length - 1);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
Expand All @@ -175,6 +176,7 @@ public void onPageScrollStateChanged(int state) {

}
});

}

/**
Expand Down

0 comments on commit 61f4e40

Please sign in to comment.