title: Can't access "findViewById" in AsyncTask
body: <p>I'm using an AsyncTask class to download data from a php file. After downloading, I want to put this data, into different TextViews, but I can't use the method findViewById.</p>
  
  <p>The problem, is that I'm doing this by separate classes, and it all within a fragment.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class RecuperarComentarisFoto extends AsyncTask&lt;String, String, String&gt;{
  private Context mContext;
  [...]
  public RecuperarComentarisFoto(Context context){
      this.mContext=context;
  }
  @Override
  protected void onPreExecute() {
      [...]
  }
  
  @Override
  protected String doInBackground(String... arg0) { 
      params.add(new BasicNameValuePair("pid", "1"));
      JSONObject json = jsonParser.makeHttpRequest(url_get_comentaris, "GET", params);
      JSONArray productObj;
      //HERE I RETRIEVE DATA FROM JSON. ITS WORKING OK.
  
      return null;
  }
  </code></pre>
  
  <p>And where I've the problem:</p>
  
  <pre><code>@Override
  protected void onPostExecute(String result) {
      super.onPostExecute(result);
      this.pDialog.dismiss();
      TextView comentariEditText = (TextView) findViewById(R.id.commentsMostrar);
  }
  </code></pre>
  
  <p>I've tried this:</p>
  
  <pre><code>        TextView comentariEditText = (TextView) mContext.findViewById(R.id.commentsMostrar);
  </code></pre>
  
  <p>But isn't working too.</p>
  
  <p>Note that I'm calling this AsyncTask from a Fragment. As you can see, I had to pass the context retrieved by getActivity() to the AsyncTask:</p>
  
  <pre><code>public class MyFragmentA extends Fragment {
  Context cont;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View myFragmentView = inflater.inflate(R.layout.fragment_a, container, false);
  
      cont=getActivity();
      new RecuperarComentarisFoto(cont).execute();
      return myFragmentView;
  }
  
  
  }
  </code></pre>
  
  <p>What should I do?</p>
  
  <p>Thank you.</p>