com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem Java Examples
The following examples show how to use
com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From RemoteControlView with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ViewPager viewPager = this.findViewById(R.id.viewpager); SmartTabLayout viewPagerTab = this.findViewById(R.id.viewpagertab); FragmentPagerItems pages = new FragmentPagerItems(this); pages.add(FragmentPagerItem.of("功能键", DemoFragment.class)); pages.add(FragmentPagerItem.of("音量键", DemoFragment1.class)); pages.add(FragmentPagerItem.of("播放键", DemoFragment.class)); pages.add(FragmentPagerItem.of("数字键", DemoFragment.class)); FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages); viewPager.setAdapter(adapter); viewPagerTab.setViewPager(viewPager); remoteControlView = this.findViewById(R.id.rcv); }
Example #2
Source File: PageFragment.java From ChangeTabLayout with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ViewPager mViewPager = (ViewPager) view.findViewById(R.id.vp); FragmentPagerItems pages = new FragmentPagerItems(getActivity()); final int page = FragmentPagerItem.getPosition(getArguments()); for (int i = 0; i < 5; i++) { Bundle bundle = new Bundle(); bundle.putInt("page", page); bundle.putInt("position", i); pages.add(FragmentPagerItem.of(String.valueOf(i), DemoFragment.class, bundle)); } FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getChildFragmentManager(), pages); //Fragment嵌套Fragment时,要用getChildFragmentManager mViewPager.setAdapter(adapter); mViewPager.setOffscreenPageLimit(2); mViewPager.setPageMargin(30); final MainActivity mainActivity = (MainActivity) getActivity(); mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { mainActivity.pageScrolled(page, position, positionOffset); } }); }
Example #3
Source File: FindDetailActivity.java From OpenEyes with Apache License 2.0 | 6 votes |
private void setAdapter() { final Bundle bundle = new Bundle(); bundle.putString("name", name); viewpagertab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { bundle.putInt("position", position); } }); //实例化适配器 FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), FragmentPagerItems.with(this) .add(FragmentPagerItem.of(TITLE[0], CommonFindFragment.class, bundle)) .add(FragmentPagerItem.of(TITLE[1], CommonFindFragment.class, bundle)) .create()); //设置适配器 findDetailViewpager.setAdapter(adapter); viewpagertab.setViewPager(findDetailViewpager); }
Example #4
Source File: MainActivity.java From ChangeTabLayout with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mViewPager = (VerticalViewPager) this.findViewById(R.id.viewpager); mTabLayout = (ChangeTabLayout) this.findViewById(R.id.tabLayout); pages = new FragmentPagerItems(this); mViewPager.setOffscreenPageLimit(title.length); for (String titleResId : title) { pages.add(FragmentPagerItem.of(titleResId, PageFragment.class)); } FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages); mViewPager.setAdapter(adapter); mTabLayout.setViewPager(mViewPager, icon, null); mTabLayout.setOnTabClickListener(new ChangeTabLayout.OnTabClickListener() { @Override public void onTabClicked(int position) { Log.d(TAG, "点击了" + position); } }); }
Example #5
Source File: DemoFragment.java From SmartTablayout with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); int position = FragmentPagerItem.getPosition(getArguments()); TextView title = (TextView) view.findViewById(R.id.item_title); title.setText(String.valueOf(position)); }
Example #6
Source File: DemoFragment.java From SmartTabLayout with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); int position = FragmentPagerItem.getPosition(getArguments()); TextView title = (TextView) view.findViewById(R.id.item_title); title.setText(String.valueOf(position)); }
Example #7
Source File: VideoFragment.java From Dota2Helper with Apache License 2.0 | 4 votes |
@Override public void init() { int position = FragmentPagerItem.getPosition(getArguments()); String videoType = NavUtil.videoTypeList[position]; mPresenter = new VideoPresenter(getActivity(), this, videoType); }
Example #8
Source File: StrategyFragment.java From Dota2Helper with Apache License 2.0 | 4 votes |
@Override public void init() { int position = FragmentPagerItem.getPosition(getArguments()); String strategyType = NavUtil.strategyTypeList[position]; mPresenter = new StrategyPresenter(getActivity(), this, strategyType); }