title: Listview with ViewHolder(s) and sections fails when scrolling
body: <p>Im building an listview with sections. i was using <a href="https://stackoverflow.com/questions/3832254/how-can-i-make-my-arrayadapter-follow-the-viewholder-pattern">this</a> answer of a post and asked a question before, but am stuck again. I think it is a pretty weird error.</p>
  <p>When i start my activity, i can see the list on the screen, just as i want it. But the moment i try to start scrolling the activity crashes. I thought i implemented everything the same way, but apparently im not.
  My adapter:</p>
  <pre><code>public class DelftAdapter extends BaseAdapter {
      
      
      private static final int TYPE_ITEM = 0;
      private static final int TYPE_SECTION = 1;
      private Activity activity;
      private  List&lt;ListItem&gt; listItems;
      private static LayoutInflater inflater=null;
      public ImageLoader imageLoader; 
      private final int[] bgColors = new int[] { R.color.list_odd, R.color.list_even };
  
      
      public DelftAdapter(Activity a, ArrayList&lt;ListItem&gt; li) {
          activity = a;
          listItems = li;
          inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          imageLoader=new ImageLoader(activity.getApplicationContext());
  
      }
  
      public int getCount() {
          return listItems.size();
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
    
      @Override
      public int getItemViewType(int position) {
          return listItems.get(position).isSection() ? TYPE_SECTION : TYPE_ITEM;
      }
  
      @Override
      public int getViewTypeCount() {
          return 2;  // sectionheader and regular item
      }
     
      
      public View getView(int position, View convertView, ViewGroup parent) {
          int type = getItemViewType(position);
          View vi=convertView;
              final ListItem li = listItems.get(position);
              ItemViewHolder itemHolder;
              SectionViewHolder sectionHolder;
    
               switch (type) {
               case TYPE_SECTION: // is sectionheader
                   if (vi == null) { //convertview==null
                  sectionHolder = new SectionViewHolder();
                  vi = inflater.inflate(R.layout.sectionedlistitem, null);
                  vi.setOnClickListener(null);
                  vi.setOnLongClickListener(null);
                  vi.setLongClickable(false);
                  sectionHolder.title = (TextView) vi.findViewById(R.id.list_header_title);
                 }else{//convertview is not null
                     sectionHolder = (SectionViewHolder)vi.getTag();
                 }
                     SectionItem si = (SectionItem)li;
                     sectionHolder.title.setText(si.getTitle());
                  break;
               case TYPE_ITEM:// no sectionheader
                  if (vi == null) { //convertview==null
                      itemHolder = new ItemViewHolder();
                      vi = inflater.inflate(R.layout.singlelistitem, null);
                      itemHolder.name=(TextView)vi.findViewById(R.id.tvname);
                      itemHolder.tip=(TextView)vi.findViewById(R.id.tvtip);
                      itemHolder.image=(ImageView)vi.findViewById(R.id.image);
                  }else{  // convertview != null
                      itemHolder = (ItemViewHolder)vi.getTag();
                  }
                  ListData ld = (ListData)li;
                  itemHolder.name.setText(ld.name);
                  itemHolder.tip.setText(ld.tip);
                          if (ld.photoUrl != null ){
                              imageLoader.DisplayImage(ld.photoUrl, itemHolder.image);
                          }else{
                              itemHolder.image.setImageURI(Uri.fromFile(new File(&quot;//assets/nopic.png&quot;)));
                          }
                          // alternating colors
                      int colorPos = position % bgColors.length;
                      vi.setBackgroundResource(bgColors[colorPos]);
                      break;
                   }
              
              
          return vi;
      
  }
      public static class SectionViewHolder {
          public TextView title;
      }
      
      public static class ItemViewHolder {
          public TextView name;
          public TextView tip;
          public ImageView image;
      }
      
  }
  </code></pre>
  <p>I build two ViewHolders for the two different kind of views. The error that occurs is NullPointerException on the <code>  itemHolder.name.setText(ld.name);</code> line.
  The thing i don't get is that the code works for the first few entrys but fails when i start scrolling. In the data i'm using, name and tip are never empty, only photoUrl might be but that is covered in the code.</p>
  <p>Anyone knows why this piece of code is failing?</p>