title: Pass data to tab fragments on onPostExecute complete
body: <p>I am trying to pass an ArrayList to <code>child tab fragment</code> from <code>main fragment</code>. The ArrayList is populated from the Asynctask task in the main fragment. I am using the ArrayList in child fragment to show the <code>ListView</code>. However, I am getting empty ListView.
  The child fragment is created before the Asynctask completion.</p>
  
  <p>I tried the following code:</p>
  
  <p>My HomeFragment (i.e. MainFragment) </p>
  
  <pre><code>public class HomeFragment extends MainFragment {
  
  private FragmentTabHost mTabHost;
  protected ArrayList&lt;ModelClass&gt; models= new ArrayList&lt;ModelClass&gt; ();
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      mTabHost = new FragmentTabHost(getActivity());
      mTabHost.setup(getActivity(), getChildFragmentManager(),
              R.layout.newcourse_screen);
  
      Bundle arg1 = new Bundle();
      arg1.putInt("Arg for Frag1", 1);
      mTabHost.addTab(mTabHost.newTabSpec("Tab1").setIndicator("Tab1"),
              CourseHomeFragment.class, arg1);
  
      Bundle arg2 = new Bundle();
      arg2.putInt("Arg for Frag2", 2);
      mTabHost.addTab(mTabHost.newTabSpec("Tab2").setIndicator("Tab2"),
              Fragment2.class, arg2);
  
      Bundle arg3 = new Bundle();
      arg2.putInt("Arg for Frag3", 3);
      mTabHost.addTab(
              mTabHost.newTabSpec("Tab3").setIndicator("Tab3"),
              Fragment3.class, arg3);
  
      for (int i = 0; i &lt; mTabHost.getTabWidget().getChildCount(); i++) {
          mTabHost.getTabWidget().getChildAt(i)
                  .setBackgroundResource(R.drawable.tab_selector);
          mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = pixels;
          TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i)
                  .findViewById(android.R.id.title);
          tv.setEllipsize(TruncateAt.MARQUEE);
          tv.setSingleLine(true);
          tv.setTextColor(Color.parseColor("#898989"));
      }
      mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab())
              .setBackgroundResource(R.drawable.tab_selector);
      mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab())
              .getLayoutParams().height = pixels;
  
      TextView tv = (TextView) mTabHost.getTabWidget()
              .getChildAt(mTabHost.getCurrentTab())
              .findViewById(android.R.id.title);
      tv.setEllipsize(TruncateAt.MARQUEE);
      tv.setSingleLine(true);
      tv.setTextColor(Color.parseColor("#ffffff"));
  
      mTabHost.setCurrentTab(0);
  
      mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
  
          @Override
          public void onTabChanged(String tabId) {
              for (int i = 0; i &lt; mTabHost.getTabWidget().getChildCount(); i++) {
                  mTabHost.getTabWidget().getChildAt(i)
                          .setBackgroundResource(R.drawable.tab_selector);
                  mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = pixels;
  
                  TextView tv = (TextView) mTabHost.getTabWidget()
                          .getChildAt(i).findViewById(android.R.id.title);
                  tv.setEllipsize(TruncateAt.MARQUEE);
                  tv.setSingleLine(true);
                  tv.setTextColor(Color.parseColor("#898989"));
              }
              mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab())
                      .setBackgroundResource(R.drawable.tab_selector);
              mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab())
                      .getLayoutParams().height = pixels;
  
              TextView tv = (TextView) mTabHost.getTabWidget()
                      .getChildAt(mTabHost.getCurrentTab())
                      .findViewById(android.R.id.title);
              tv.setEllipsize(TruncateAt.MARQUEE);
              tv.setSingleLine(true);
              tv.setTextColor(Color.parseColor("#ffffff"));
          }
      });
  
      return mTabHost;
  }
  
      @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onActivityCreated(savedInstanceState);
      new GetCourses().execute("");
  
  }
  
  private class GetData extends AsyncTask&lt;String, Void, String&gt; {
  
      @Override
      protected String doInBackground(String... params) {
          // TODO Auto-generated method stub
  
              // Performing operation and updating the Arraylist models //
  
          return null;
      }
  
      @Override
      protected void onPreExecute() {
          // TODO Auto-generated method stub
          super.onPreExecute();
          AppData.showSpinnerDialog(getActivity(), false);
      }
  
      @Override
      protected void onProgressUpdate(Void... values) {
          // TODO Auto-generated method stub
          super.onProgressUpdate(values);
      }
  
      @Override
      protected void onPostExecute(String result) {
          // TODO Auto-generated method stub
          super.onPostExecute(result);
          AppData.dismisssSpinnerDialog();
      }
  }
  }
  </code></pre>
  
  <p>My CouseHomeFragment (i.e. ChildTabFragment)</p>
  
  <pre><code>public class CourseHomeFragment extends Fragment {
  
      private ArrayList&lt;CurriculumModel&gt; curriculum = new ArrayList&lt;CurriculumModel&gt;();
  ListView lview;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View V = inflater.inflate(R.layout.newcourse_screen, container, false);
      lview = (ListView) V.findViewById(R.id.listView_course);
  
      ((PullToRefreshListView) lview)
              .setOnRefreshListener(new OnRefreshListener() {
                  @Override
                  public void onRefresh() {
                      // Do work to refresh the list here.
                      // new GetCourses().execute("");
                      ((PullToRefreshListView) lview).onRefreshComplete();
                  }
              });
  
      CourseRowAdapter mAdapter = new CourseRowAdapter(getActivity(),
              models, true);
      mAdapter.notifyDataSetChanged();
      lview.setAdapter(mAdapter);
  
      return V;
  }
  }
  </code></pre>
  
  <p>CourseRowAdapter</p>
  
  <pre><code>public class CourseRowAdapter extends BaseAdapter {
  
  public Activity context;
  private ArrayList&lt;CurriculumModel&gt; curriculumItems;
  private TypedArray courseIcons;
  boolean status;
  
  public CourseRowAdapter(Activity context,
          ArrayList&lt;CurriculumModel&gt; curriculumItems, boolean status) {
      super();
      this.context = context;
      this.curriculumItems = curriculumItems;
      this.status = status;
      courseIcons = context.getResources().obtainTypedArray(
              R.array.course_icons);
  
  }
  
  
  
  public void setCurriculumItems(ArrayList&lt;CurriculumModel&gt; curriculumItems) {
      this.curriculumItems = curriculumItems;
  }
  
  
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return curriculumItems.size();
  }
  
  @Override
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return null;
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      return View;
  }
  </code></pre>