Android Combining ViewPager, Fragments and AsyncTask..pages are blank
<p>I try to get a ViewPager with 3 different Pages. All three Pages have a GridView with Pictures and Text. I'm fetching the data from a server in a Json Format.</p>

<p>The issue is... If I'm getting the data from the server ViewPager pages in the GridView  are blank. Now I'm using Fragment, but it doesn't work.</p>

<p>TestFragment is just a simple Layout with no server-data(just to test if the ViewPager works)...this page works. PersonenFragment should display the server data but it doesn t. As display the data in the GridView works well without ViewPager problem is not in the Code of the "PersonsListAdapter".</p>

<p>I think the problem is that the page is shown by the ViewPager before the GridView is filled with the data from the asyncTask..as it takes some time. What do I have to do ?</p>

<pre><code>public class PersonenFragmentActivity extends FragmentActivity{

private MyAdapter mAdapter;
private ViewPager mPager;
public Activity act = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.personen_view_pager);
   act= this;
    mAdapter = new MyAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);


}

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

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

    @Override
    public Fragment getItem(int position) {

        switch (position) {
        case 0:

           return new TestFragment();
        case 1:

            return new PersonenFragment("ProfessorInnen", act);

        default:
            return null;
        }
    }
}
}
</code></pre>

<p>The PersonFragment</p>

<pre><code>public class PersonenFragment extends Fragment {


private int mCurrentPage;
private String personenKategorie;
private Activity activity;
private View view;
    private GriedView gv ;


public PersonenFragment(String personenKategorie, Activity activity) {
    this.personenKategorie = personenKategorie;
    this.activity = activity;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

//readWebPage contains the asyncTask which downloads dataFromServer and returns an ArrayList with PersonObjects with the data in it
    DownloadPersonen download = new DownloadPersonen();
    download.readWebpage(this.personenKategorie);

}



@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
 //layout.Personen is the Layout with the Grid
  gv = (GriedView) inflater.inflate(R.layout.personen, container, false);
  return gv;
}
</code></pre>

<p>On postExecute from AsyncTask DownloadPersonen </p>

<pre><code>    @Override
    protected void onPostExecute(ArrayList&lt;Person&gt; personen) {

    GridView grid= (GridView) ll.findViewById(R.id.personen_grid_view);
    PersonsListAdapter p = new PersonsListAdapter(activity,personen);
    grid.setAdapter(p);

    }
</code></pre>
