title: Downloading ImageView for API android
body: <p>I'm working on an API class for other developers to use.
  In one the my functions there is an ImageView array that I download and assign it to a static ArrayList for the developer to use it.</p>
  
  <p>For getting the ImageViews from the internet I am using a class which download them in async method.
  My problem is that if I don't init the ImageView with an ID from the resources and i just init it with 
  ImageView imgView = new ImageView(activity); //activity is passed by the calling class
  I fail to use/display the images in the activity which calls this function.</p>
  
  <p>Some of my code:</p>
  
  <p>this is the function in my api class (not an activity)</p>
  
  <pre><code>JSONArray banners = new JSONArray(result);
  
  if(banners != null)
  {
      for(int i = 0; i &lt;    banners.length(); i++)
  {
  //ImageView imgView =(ImageView)activity.findViewById(R.id.imageView3); 
  ImageView imgView = new ImageView(activity);
  
  JSONObject jsonObjRecv = banners.getJSONObject(i);
  
  String ImageUrl = jsonObjRecv.getString("image"); 
  
  ImageLoad downloader = new ImageLoad(imgView);                                  
  downloader.execute(ImageUrl);
  
  imageViewsArray.add(imgView);
  </code></pre>
  
  <p>MainAcitiy:</p>
  
  <pre><code>ImageView imView = (ImageView)findViewById(R.id.imageView3);
  imView = AlbosBanners.imageViewsArray.get(0);
  </code></pre>
  
  <p>This part of the code I do when the handler send a message that download is finished, but the image view in the activity keep showing nothing, instead of the downloaded imageview.
  imageView3 is an id of imageview of the MainActivity content xml</p>
  
  <p>Note:
  If I do use this line in my function:</p>
  
  <pre><code>ImageView imgView =(ImageView)activity.findViewById(R.id.imageView3); 
  </code></pre>
  
  <p>it is working.</p>
  
  <p>Just to make clear - in the api I WILL NOT know the activities and xml of the application which it is going to be used in.
  I hope I explained it clearly. 
  What am I doing wrong?</p>