资源简介
FragmentTabhost fragment 中的Tablayout+ViewPager ,ViewPager高度自适应
代码片段和文件信息
package com.tjstudy.scrollviewviewpagerdemo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class BlankFragment extends Fragment {
private TabLayout tl;
private CustomViewpager vp;
public BlankFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater ViewGroup container
Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_main container false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
tl = (TabLayout) getView().findViewById(R.id.tl);
vp = (CustomViewpager) getView().findViewById(R.id.vp);
List tabtitles = new ArrayList<>();
tabtitles.add(“学校介绍“);
tabtitles.add(“入学升学“);
tabtitles.add(“相关视频“);
List fragments = new ArrayList<>();
fragments.add(OverseasStudyTab1Fragment.newIntance(vp));
fragments.add(OverseasStudyTab2Fragment.newIntance(vp));
fragments.add(OverseasStudyTab3Fragment.newIntance(vp));
for (String tab : tabtitles) {
tl.addTab(tl.newTab().setText(tab));
}
// 默认第一个选中
tl.getTabAt(0).select();
tl.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
vp.setCurrentItem(tab.getPosition());
vp.resetHeight(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
vp.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager() tabtitles fragments));
tl.setupWithViewPager(vp);
vp.setOffscreenPageLimit(3);
vp.setCurrentItem(0);
vp.resetHeight(0);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-13 11:56 ScrollViewViewPagerDemo\
文件 127 2018-09-13 09:48 ScrollViewViewPagerDemo\.gitignore
文件 1418 2018-09-13 11:55 ScrollViewViewPagerDemo\ReadMe.md
文件 900 2018-09-13 11:49 ScrollViewViewPagerDemo\ScrollViewViewPagerDemo.iml
目录 0 2018-09-13 11:56 ScrollViewViewPagerDemo\app\
文件 8 2018-09-13 09:48 ScrollViewViewPagerDemo\app\.gitignore
文件 10337 2018-09-13 11:51 ScrollViewViewPagerDemo\app\app.iml
文件 1008 2018-09-13 10:19 ScrollViewViewPagerDemo\app\build.gradle
目录 0 2018-09-13 11:56 ScrollViewViewPagerDemo\app\libs\
文件 936 2018-09-13 09:48 ScrollViewViewPagerDemo\app\proguard-rules.pro
目录 0 2018-09-13 11:56 ScrollViewViewPagerDemo\app\src\
目录 0 2018-09-13 09:50 ScrollViewViewPagerDemo\app\src\main\
文件 749 2018-09-13 09:50 ScrollViewViewPagerDemo\app\src\main\AndroidManifest.xm
目录 0 2018-09-13 09:48 ScrollViewViewPagerDemo\app\src\main\java\
目录 0 2018-09-13 09:48 ScrollViewViewPagerDemo\app\src\main\java\com\
目录 0 2018-09-13 09:48 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\
目录 0 2018-09-13 11:53 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\
文件 2469 2018-09-13 10:29 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\BlankFragment.java
文件 2438 2018-09-13 10:12 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\CustomViewpager.java
文件 13018 2018-09-13 10:50 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\FragmentStatusSaveTabHost.java
文件 1911 2018-09-13 11:53 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\MainActivity.java
文件 992 2018-09-13 10:02 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\MyFragmentPagerAdapter.java
文件 888 2018-09-13 10:13 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\OverseasStudyTab1Fragment.java
文件 945 2018-09-13 10:13 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\OverseasStudyTab2Fragment.java
文件 945 2018-09-13 10:13 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\OverseasStudyTab3Fragment.java
文件 371 2018-09-13 10:54 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\TableConfig.java
文件 2519 2018-09-13 10:07 ScrollViewViewPagerDemo\app\src\main\java\com\tjstudy\scrollviewviewpagerdemo\WrapContentHeightViewPager.java
目录 0 2018-09-13 09:48 ScrollViewViewPagerDemo\app\src\main\res\
目录 0 2018-09-13 11:56 ScrollViewViewPagerDemo\app\src\main\res\drawable\
目录 0 2018-09-13 11:51 ScrollViewViewPagerDemo\app\src\main\res\layout\
文件 1107 2018-09-13 10:27 ScrollViewViewPagerDemo\app\src\main\res\layout\activity_main.xm
............此处省略33个文件信息
评论
共有 条评论