title: Getting data to fragment class from async task
body: <p>I am beginner in android. How can i get the data from <strong>AsyncTask</strong> to placeholder fragment2 class i cannot  access  actors list from the AsyncTask.If i get the data as a array in placement fragment i can use that to create a list view from the data retrieved from <strong>async task</strong>.</p>
  
  <pre><code>public static class PlaceholderFragment2 extends Fragment {
  
  
      private static final String ARG_SECTION_NUMBER = "section_number";
  
      ListView list;
      ActorsAdapter adapter;
      ArrayList&lt;Actors&gt; actorsList;
  
  
  
  
      public static PlaceholderFragment2 newInstance(int sectionNumber) {
          PlaceholderFragment2 fragment = new PlaceholderFragment2();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      public PlaceholderFragment2() {
  
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.fragment_json, container, false);
          list = (ListView) rootView.findViewById(R.id.listView_news);
          actorsList = new ArrayList&lt;Actors&gt;();
  
          new ActorsAsyncTask().execute("https://myurl.com");
  
  
  
          //EDITED Code
  
  
  
  
  
  
  
          return rootView;
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          ((MyActivity) activity).onSectionAttached(
                  getArguments().getInt(ARG_SECTION_NUMBER));
      }
  }
  
  public static class ActorsAsyncTask extends AsyncTask&lt;String,Void,Boolean&gt;
  {
      @Override
      protected Boolean doInBackground(String... strings) {
  
          HttpClient client = new DefaultHttpClient();
          HttpPost post = new HttpPost(strings[0]);
  
  
          try {
              HttpResponse response = client.execute(post);
              int status = response.getStatusLine().getStatusCode();
  
                  HttpEntity entity = response.getEntity();
                  String data = EntityUtils.toString(entity);
              if(data != null) {
  
                  JSONObject object = new JSONObject(data);
                  String results = object.getString("results");
                  Log.d("Response: ", "&gt; " + results);
  
                  JSONObject object1 = new JSONObject(results);
                  JSONArray jArray = object1.getJSONArray("collection1");
  
  
                  for (int i = 0; i &lt; jArray.length(); i++) {
  
                      Actors actor = new Actors();
                      JSONObject object2 = jArray.getJSONObject(i);
  
  
                      String property1 = object2.getString("property1");
                      JSONObject object3 = new JSONObject(property1);
                      actor.setHref(object3.getString("href"));
                      String href = object3.getString("href");
                      actor.setText(object3.getString("text"));
                      String text = object3.getString("text");
                      // Log.d("text", text);
                      Log.d("href", href);
                      Log.d("text",text);
  
                   actorsList.add(actor);////////////////not working
  
  
  
                  }
              }
                  else{
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
          } catch (IOException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
          return null;
      }
  
  }
  
  public class Actors {
      private String text ;
      private String href;
  
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
      public String getHref() {
          return href;
      }
  
      public void setHref(String href) {
          this.href = href;
      }
  
      public Actors(){
  
      }
  }
  </code></pre>