title: ViewPager, ListView, and AsyncTask, first page blank, all data in the second page
body: <p>There is a similar question here, <a href="https://stackoverflow.com/questions/9525279/activity-using-viewpager-pageradapter-and-asynctask-causes-a-blank-view">Activity using ViewPager, PagerAdapter and AsyncTask causes a blank view</a>, but my problem is more than that.</p>
  
  <p>I have a ViewPager that  contains a ListView. This ListView is populated by an asyncTask. The listview displays the data, but not correctly. The first page is always blank, and the second page contains BOTH pages data.</p>
  
  <p>I've simplified my asynctask to be sure tit wasnt something there that was causing the issue.</p>
  
  <pre><code>@Override
  public Object instantiateItem(View pager, int position){
     // Log.d("PAGER", Integer.toString(position));
     ctx = pager.getContext();
     v = new ListView(ctx);
     new CreateArrayListTask().execute(URLS[position]);
     ((ViewPager)pager).addView(v, 0); 
     return v;
  }
  </code></pre>
  
  <p><strong>CreateArrayListTask</strong></p>
  
  <pre><code>private class CreateArrayListTask extends AsyncTask&lt;String, Void, ArrayList&lt;String&gt;&gt; {               
     @Override
     protected ArrayList&lt;String&gt; doInBackground(String... params) {
       linkArray.add("Item 1");
       linkArray.add("Item 2");
       return linkArray;
     }
  </code></pre>
  
  <p><strong>onPostExecute</strong>              </p>
  
  <pre><code>protected void onPostExecute(ArrayList&lt;String&gt; linkArray) {
     ArrayAdapter&lt;String&gt; a = new ArrayAdapter&lt;String&gt;(ctx, android.R.layout.simple_list_item_1, linkArray);
     v.setAdapter(a);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/3IXtY.png" alt="enter image description here"></p>