title: CursorAdapter slow/jerky scroll
body: <p>I've got a ListActivity that's using a CursorAdapter to draw a dataset in a table format. I originally used a TableLayout (and drew the entire table) but I was concerned that this was using too much memory (and drawing the page was slow) so I'm now investigating using a CursorAdapter.</p>
  
  <p>The XML layout for the body of the activity looks like this (note the use of a HorizontalScrollView, which may be a cause):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"
      android:id="@+id/layout_query_viewer"&gt;
  
      &lt;TextView
          android:id="@+id/query_table_name"
          style="@style/ActivityTitle" /&gt;
  
      &lt;HorizontalScrollView
          android:id="@+id/hsvMainContent"
          android:scrollbars="none"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
          &lt;LinearLayout
              android:id="@+id/llMainContent"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
              &lt;LinearLayout
                  android:id="@+id/fixed_headers"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;ListView
                  android:id="@android:id/android:list"
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"/&gt;
          &lt;/LinearLayout&gt;
      &lt;/HorizontalScrollView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The CursorAdapter looks like this:</p>
  
  <pre><code>private class QueryAdapter extends CursorAdapter {
      public QueryAdapter(Context context) {
          super(context, null);
      }
  
      @Override
      public View newView(Context context, Cursor cursor, ViewGroup parent) {
          /*
           * I'm deliberately not inflating here as I'm synchronizing a remote
           * database, so I don't know how many columns my query will return.
           */
          LinearLayout layout = new LinearLayout(context);
          ViewHolder holder = new ViewHolder(cursor.getColumnCount());
          layout.setTag(holder);
  
          for (int i = 1; i &lt; cursor.getColumnCount(); i++) {
              TextView cell = new TextView(context);
  
              holder.cells[i] = cell;
  
              cell.setBackgroundColor(Color.WHITE);
              cell.setMinimumWidth(mColumnWidths[i]);
              cell.setPadding(1, 1, 1, 1);
  
              layout.addView(cell);
          }
  
          return layout;
      }
  
      @Override
      public void bindView(View view, Context context, Cursor cursor) {
          ViewHolder holder = (ViewHolder)view.getTag();
  
          for (int i = 1; i &lt; cursor.getColumnCount(); i++) {
              holder.cells[i].setText(cursor.getString(i));
          }
      }
  }
  
  static class ViewHolder {
      TextView[] cells;
  
      public ViewHolder(int size) {
          cells = new TextView[size];
      }
  }
  </code></pre>
  
  <p>I was happy with the scrolling performance when I drew the entire table but now that I've switched to the CursorAdapter the scrolling is jerky (and I mean unacceptably jerky). The CursorAdapter approach seems logically the correct decision architecturally but unless I can fix the scroll problem then I'll have to go back to drawing the entire table.</p>
  
  <p>Has anyone else experienced this or can shed some light on what I doing wrong?</p>