title: cursoradapter with different row layouts
body: <p>I'm trying to create a custom cursoradapter that will use two different layouts depending on some data in the cursor. I keep reading about 'overriding getViewTypeCount() and getItemViewType()' to make this happen but I can't seem to figure out how to implement this..</p>
  
  <p>This is my code for the bindView and new View methods:</p>
  
  <pre><code>@Override
  public void bindView(View view, Context context, Cursor cursor) {
      TextView tView = (TextView) view.findViewById(R.id.TextView1);
      tView.setText("The text");
  }
  
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
      return mInflater.inflate(R.layout.item1, parent, false);
  }
  </code></pre>
  
  <p>.</p>
  
  <p><strong>EDIT:</strong>
  Now I got this working, but I want to choose what rowlayout to use depending on some data in the cursor and I can't get that working.. anybody got some ideas?</p>
  
  <pre><code>@Override
  public int getItemViewType(int position) {
      return position % 2;
  }
  
  @Override
  public int getViewTypeCount() {
      return 2;
  }
  
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
      ViewHolder holder = (ViewHolder) view.getTag();
      holder.txtAddress
              .setText("blabla");
  }
  
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
      ViewHolder holder = new ViewHolder();
      View v = null;
      int type = cursor.getPosition() % 2;
      if(type == 0) {
          v = mInflater.inflate(R.layout.item, parent, false); 
      } else {
          v = mInflater.inflate(R.layout.item2, parent, false);
      }
  
      holder.txtAddress = (TextView) v.findViewById(R.id.tvName);
  
      v.setTag(holder);
      return v;
  }
  </code></pre>