title: Android Fragment lifecycle issue on change orientation
body: <p>I have an Activity which use a Viewpager.Viewpager has a few Fragments and of course Fragments are prepared by a FragmentPagerAdapter.Let me give an example :</p>
  
  <p>Here is my activity:</p>
  
  <pre><code>public class SampleActivity extends FragmentActivity {
  
  private ViewPager viewpager;
  private SampleFragmentAdapter sample_fragment_adapter;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.sample_layout);
      viewpager = (ViewPager)findViewById(R.id.sample_pager);
      sample_fragment_adapter = new SampleFragmentAdapter(getSupportFragmentManager(),this);
      viewpager.setAdapter(sample_fragment_adapter);
  }
  </code></pre>
  
  <p>FragmentPagerAdapter:</p>
  
  <pre><code>public class SampleFragmentAdapter extends FragmentPagerAdapter{
  
   private Context context;
   private int fCount;
   private SampleFragment[] fragment_list;
  
      public SampleFragmentAdapter(FragmentManager fm,Context context) {
          super(fm);
          this.context=context;
          fragment_list=new SampleFragment[8];
          fCount=fragment_list.length;
          for(int i=0;i&lt;8;i++){
              fragment_list[i]=new SampleFragment();
              fragment_list[i].setList(getList());
          }
      }
  }
  
  @Override
      public Fragment getItem(int position) {
          return fragment_list[position];
      }
  
      @Override
      public int getCount() {
          return fCount;
      }
  
  public void getList(){
  
          //here , an arraylist which is not null is returned
          //this arraylist includes data using by listview in fragment
  }
  </code></pre>
  
  <p>And finally my Fragment class (Fragment includes a listview):</p>
  
  <pre><code>public class SampleFragment extends Fragment implements AdapterView.OnItemClickListener{
  
  private View view;
  private ListView sample_list_view;
  private LessonListAdapter sample_list_adapter;
  private ArrayList&lt;Sample&gt; sample_list;
  
  public void setList(ArrayList&lt;Sample&gt; sample_list){
      this.sample_list=sample_list;
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
       view=inflater.inflate(R.layout.sample_list_layout, container, false);
       sample_list_view=(ListView)view.findViewById(R.id.sample_list_view);
       sample_list_adapter=new SampleListAdapter(getActivity(),sample_list);
       sample_list.setAdapter(sample_list_adapter);
       return view;
  }
  </code></pre>
  
  <p>My problem : When activity starts on any orientation , it works perfectly.But when I change orientation , I guess activity starts again and onCreateView method in SampleFragment is called before setList() method.So null arraylist goes to sample_list_adapter but Fragment view can not prepared untill arraylist is ready.I guess this is lifecycle problem of Fragment.How can solve ? </p>
  
  <p>Thanks for any help       </p>