title: ListView - Loading Images For Non Visible Items (Using Android-Universal-Image-Loader)
body: <p>In my fragment, I have a ListView of items which contain some text and an image that takes the entire width of the screen. The images are loaded from a URL and I'm using <a href="https://github.com/nostra13/Android-Universal-Image-Loader" rel="nofollow">Android-Universal-Image-Loader</a> for that.</p>
  
  <p>I'm using a custom adapter (<code>extends BaseAdapter</code>) and assigning it to the list this way:</p>
  
  <pre><code>public class MyAdapter extends BaseAdapter {
      private LayoutInflater inflater;
      private List&lt;Offer&gt; offers;
      private Context context;
  
      public MyAdapter(Context context, List&lt;Offer&gt; offers) {
          super();
          this.context = context;
          this.inflater = LayoutInflater.from(context);
          this.offers = offers;
      }
      @Override
      public int getCount() {
          return offers.size();
      }
      @Override
      public Object getItem(int position) {
          return offers.get(position);
      }
      @Override
      public long getItemId(int position) {
          return position;
      }
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          final View view;
          if (convertView == null) {
              view = inflater.inflate(R.layout.offer_list_view, parent, false);
          } else {
              view = convertView;
          }
  
          final Offer offer = offers.get(position);           
          ImageView image = (ImageView) view.findViewById(R.id.offer_list_item_image);
          MyImageLoader.getInstance(context).displayImage(offer.getImageUrl(), image); //load the image using the universal image loader
          TextView offerTitle = (TextView) view.findViewById(R.id.offer_list_item_title);         
          offerTitle.setText(offer.getTitle());
          return view;
      }
  }
  </code></pre>
  
  <p>Typically ~2.5 items fit to the screen height. When I scroll down the adpater's getView method is called and the next images are loaded. This isn't the nicest user behavior and I want more than 2-3 items to load every time. </p>
  
  <p>For instance, I want that the itmes/images #3 &amp; #4, that aren't visible at the beginning, will be loaded too so that when I scroll to it, they will already be there.</p>
  
  <p>How can I extends the number of calls to getView so that items that aren't currently visible will be populated too?</p>