public static DummyRecyclerViewFragment newInstance(
     String title, int count, @LayoutRes int headerLayout) {
   DummyRecyclerViewFragment fragment = new DummyRecyclerViewFragment();
   Bundle bundle = new Bundle();
   bundle.putString(ARG_TITLE, title);
   bundle.putInt(ARG_COUNT, count);
   bundle.putInt(ARG_HEADER_LAYOUT, headerLayout);
   fragment.setArguments(bundle);
   return fragment;
 }
コード例 #2
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
    adapter.addFragment(
        DummyRecyclerViewFragment.newInstance(
            "Cat", 100, R.layout.item_action_bar_tab_layout_spacing),
        "Cat");
    adapter.addFragment(
        DummyRecyclerViewFragment.newInstance(
            "Dog", 100, R.layout.item_action_bar_tab_layout_spacing),
        "Dog");
    adapter.addFragment(
        DummyRecyclerViewFragment.newInstance(
            "Mouse", 100, R.layout.item_action_bar_tab_layout_spacing),
        "Mouse");
    adapter.addFragment(
        DummyRecyclerViewFragment.newInstance(
            "Chicken", 5, R.layout.item_action_bar_tab_layout_spacing),
        "Chicken");
    adapter.addFragment(
        DummyNestedScrollViewFragment.newInstance(
            getString(R.string.text_long), R.layout.item_action_bar_tab_layout_spacing),
        "Duck");
    adapter.addFragment(
        DummyRecyclerViewFragment.newInstance(
            "Bird", 100, R.layout.item_action_bar_tab_layout_spacing),
        "Bird");
    adapter.addFragment(
        DummyNestedScrollViewFragment.newInstance(
            getString(R.string.text_short), R.layout.item_action_bar_tab_layout_spacing),
        "Tiger");

    // PagerAdapter have to implement `me.henrytao.smoothappbarlayout.PagerAdapter` in order to make
    // it work with `SmoothAppBarLayout`
    if (adapter instanceof PagerAdapter) {
      vViewPager.setAdapter(adapter);
    }
    vTabLayout.setupWithViewPager(vViewPager);
    vTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
  }
 public static DummyRecyclerViewFragment newInstance(String title, int count) {
   return DummyRecyclerViewFragment.newInstance(title, count, 0);
 }