SimpleCursorAdapter bindView 方法被多次调用

March 21, 2013

现象:实现了一个SimpleCursorAdapter , 其中bindView()方法被多次调用,通过日志发现,被调用的位置是0。


onMeasure(int widthMeasureSpec, int heightMeasureSpec)

mItemCount = mAdapter == null ? 0 : mAdapter.getCount();
final int count = mItemCount;
if (count > 0)
final View child = obtainView(0, mIsScrap);


View obtainView(int position, boolean[] isScrap)

scrapView = mRecycler.getScrapView(position);
View child;
if (scrapView != null) {
child = mAdapter.getView(position, scrapView, this);
child = mAdapter.getView(position, null, this);


public View getView(int position, View convertView, ViewGroup parent) {
        if (!mDataValid) {
            throw new IllegalStateException("this should only be called when the cursor is valid");
        if (!mCursor.moveToPosition(position)) {
            throw new IllegalStateException("couldn't move cursor to position " + position);
        View v;
        if (convertView == null) {
            v = newView(mContext, mCursor, parent);
        } else {
            v = convertView;
        bindView(v, mContext, mCursor);
        return v;



this is out of our control. The android renders a view at least 3 times 
before it gets displayed.
The first two have something to do with measurement. For the grid view, 
they assume all the views
are the same size (the size of the view number 0) and then display the 
rest.  so bind view may be called
20 or 30 times per redraw.  We should make it as simple as possible.

--- EOF ---