I created a listview that has a custom SimpleCursorAdapter. I want to place a header in the first element in the list. 8 views fit on the screen at a time. When I scroll down to the ninth view, the header of the 1st element appears. At least I believe that is what is happening. I removed a button above the listview allowing all of the elements to appear on screen and only the first element had the header.
I believe I am forcing a new view to be inflated each time. I have read up a bit on convertview and it appears to be something that you have to implement manually.
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
int position = cursor.getPosition();
View v;
v = inflater.inflate(R.layout.roster_lv_row_entry_with_header, parent, false);
if(position > 0)
v = inflater.inflate(R.layout.roster_lv_row_entry_no_header, parent, false);
return v;
You shoul override the
(final int position, View convertView, ViewGroup parent)method in your adapter class, andconvertViewparameter anew value (if necessary, but better just use it if it’s the right type, and fill it with the proper data based on
yourListData.get(position), whereyourListDatais e.g. aList<?>extension.)