Android: using savedInstanceState with Fragment error
<p>my code:</p>

<p>Main Activity</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

..
mAdapter = new MyAdapter(getFragmentManager());
            mPager = (ViewPager) findViewById(R.id.pager);
            mPager.setAdapter(mAdapter);
            mPager.setOnPageChangeListener(new MyPageChangeListener());


private class MyPageChangeListener extends
            ViewPager.SimpleOnPageChangeListener {
        @Override
        public void onPageSelected(int position) {
            focusedPage = position;
        }
    }

public class MyAdapter extends FragmentStatePagerAdapter {
    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public int getCount() {
        return qNumberSum;
    }

    @Override
    public Fragment getItem(int position) {
        ArrayListFragment alf = new ArrayListFragment();
        return alf.newInstance(position);
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position,
            Object object) {
        ArrayListFragment alf = (ArrayListFragment) object;
        mCurrentView = alf.getView();

    }

}

public class ArrayListFragment extends Fragment {
    int mNum;


    /**
     * Create a new instance of CountingFragment, providing "num" as an
     * argument.
     */
    ArrayListFragment newInstance(int num) {
        ArrayListFragment f = new ArrayListFragment();

        // Supply num input as an argument.
        Bundle args = new Bundle();
        args.putInt("num", num);
        f.setArguments(args);

        return f;
    }

    /**
     * When creating, retrieve this instance's number from its arguments.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mNum = getArguments() != null ? getArguments().getInt("num") : 1;
    }
</code></pre>

<p>When savedInstanceState is null (for example when the user starts over) everything works ok.
But when not null i get this exception:</p>

<p>04-29 14:10:00.398: E/AndroidRuntime(29348): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.Android.Prj.DispKl$ArrayListFragment: make sure class name exists, is public, and has an empty constructor that is public</p>

<p>Why is it so and how can I fix it? </p>
