From the source code of CursorAdapter.java , CursorAdapter extends BaseAdapter .
And you can see the implementation of the getView() function:
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; }
It does what we usually do in getView() (inflate the view if convertView is null, otherwise the view is reused), so itβs easy to make it easier for the developer OR to force the user to use the ViewHolder template.
PS: Some developers call the bindViews () function in the implementation of newView (), from the source code you can see that this is not necessary.
source share