Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In just created Activity you can find inner class <code>SectionsPagerAdapter</code>. Look at this method:</p> <pre><code>@Override public Fragment getItem(int i) { Fragment fragment = new DummySectionFragment(); Bundle args = new Bundle(); args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1); fragment.setArguments(args); return fragment; } </code></pre> <p>This method for every tab returns instance of DummySectionFragment with only different bundles. If you want to create fragments with different views for every tab you should check value of <code>i</code> variable and according to this value create proper fragment. For example:</p> <pre><code>@Override public Fragment getItem(int i) { Fragment fragment; switch(i){ case 0: fragment = new MyFragment1(); break; case 1: fragment = new MyFragment2(); break; case 3: fragment = new MyFragment3(); break; default: throw new IllegalArgumentException("Invalid section number"); } //set args if necessary Bundle args = new Bundle(); args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1); fragment.setArguments(args); return fragment; } </code></pre> <p>Instead of <code>DummySectionFragment</code> class create three classes: MyFragment1, MyFragment2, MyFragment2 and for each, inside method <code>onCreateView</code> create or inflate view, for example:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.my_fragment1.xml, null); return v; </code></pre> <p>}</p> <p>Where R.layout.my_fragment1.xml is layout of your MyFragment1 fragment.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload