I'm passing id form FirstFragment to SecondFragment. I need that I'd to send POST request to web service to retrieve JSON, which I need to create content of SecondFragment. SecondFragment is ListView with custom layout. I'm adding that layout with my custom adapter class (MyAdapter). For JSON I also have AsyncTask class (GetCategoryTas) The problem is that the SecondFragment is created before service give me result back. So content is always blank. How can I fix this.

FirstFragment:

```
@Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Bundle bundle = new Bundle();
    bundle.putString("id", menuList.get(position).getAlias());
    categoryPage = new FragmentCategoryPage();
    categoryPage.setArguments(bundle);
    transaction = manager.beginTransaction();
    transaction.replace(R.id.mainContainer, categoryPage, "CategoryPage");
    transaction.addToBackStack("CategoryPage");
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.commit();

}

```

SecondFragment:

```
public class FragmentCategoryPage extends Fragment implements OnItemClickListener {

    private ListView lvCategory;
    private List<NameValuePair> pair;

    private ArrayList<ItemCategory> itemCatList = new ArrayList<ItemCategory>();
    private ItemCategory itemCat;

    private MyAdapter myAdapter;
    private Context context;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_category, container, false);

        context = getActivity();

        String id = getArguments().getString("id");
        pair = new ArrayList<NameValuePair>();
        pair.add(new BasicNameValuePair("category", id));
        new GetCategoryTask().execute();

        lvCategory = (ListView) view.findViewById(R.id.lvCategory);

        myAdapter = new MyAdapter();
        lvCategory.setAdapter(myAdapter);
        lvCategory.setOnItemClickListener(this);

        return view;
    }

    // Creating own adapter for categories
    class MyAdapter extends BaseAdapter {

        @Override
        public View getView(final int pos, View convertView, ViewGroup parent) {
            View row = null;

            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = inflater.inflate(R.layout.item_layout_category, parent, false);
            } else {
                row = convertView;
            }

            TextView tvCatTitle = (TextView) row.findViewById(R.id.tvCategoryTitle);
            TextView tvCatDate = (TextView) row.findViewById(R.id.tvCategoryDate);
            ImageView ivCatImage = (ImageView) row.findViewById(R.id.ivCategoryImage);

            return row;
        }

        @Override
        public int getCount() { return itemCatList.size(); }
        @Override
        public Object getItem(int pos) { return null; }
        @Override
        public long getItemId(int pos) { return 0; }
    }

    public class GetCategoryTask extends AsyncTask<String, Void, Boolean> {

        @Override
        protected Boolean doInBackground(String... params) {

            try {
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(Variables.URL_CATEGORY);
                httpPost.setEntity(new UrlEncodedFormEntity(pair));

                HttpResponse httpResponse = httpClient.execute(httpPost);
                HttpEntity httpEntity = httpResponse.getEntity();
                String data = EntityUtils.toString(httpEntity);

                int status = httpResponse.getStatusLine().getStatusCode();

                if (status == HttpStatus.SC_OK) {

                    JSONArray jArray = new JSONArray(data);
                    for (int i = 0; i < jArray.length(); i++) {

                        JSONObject jRealObject = jArray.getJSONObject(i);

                        itemCat = new ItemCategory();
                        itemCat.setId(jRealObject.get("id").toString());
                        itemCat.setTitle(jRealObject.get("title").toString());
                        itemCat.setImage_name(jRealObject.get("image_name").toString());

                        itemCatList.add(itemCat);
                    }

                    return true;
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (JSONException e) {
                e.printStackTrace();
            }
            return false;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);

            if(result == false) {
                Toast.makeText(context, Variables.ERROR_MESSAGE, Toast.LENGTH_SHORT).show();
            }
        }
    }
}

```

How can I fix this problem?