Java Code Examples for com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem#getPosition()

The following examples show how to use com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem#getPosition() . 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: PageFragment.java    From ChangeTabLayout with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: DemoFragment.java    From SmartTablayout with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: DemoFragment.java    From SmartTabLayout with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: VideoFragment.java    From Dota2Helper with Apache License 2.0 4 votes vote down vote up
@Override
public void init() {
    int position = FragmentPagerItem.getPosition(getArguments());
    String videoType = NavUtil.videoTypeList[position];
    mPresenter = new VideoPresenter(getActivity(), this, videoType);
}
 
Example 5
Source File: StrategyFragment.java    From Dota2Helper with Apache License 2.0 4 votes vote down vote up
@Override
public void init() {
    int position = FragmentPagerItem.getPosition(getArguments());
    String strategyType = NavUtil.strategyTypeList[position];
    mPresenter = new StrategyPresenter(getActivity(), this, strategyType);
}