I want to display a very simple separator in my listview. I have made a custom adapter that extends 'SimpleAdapter' and my implementation works somewhat. It displays the dividers and my list correct but once I start to scroll and then scroll back up the dividers gets messed up, placed instead of listitems etc. Sometime when I scroll some more it will look correct again. This is my code for 'getView'
@Override
public View getView(int position, View convertView, ViewGroup parent){
if(((String)items.get(position).get("name")).startsWith("-")){
View divider = inflater.inflate(R.layout.list_separator, null);
TextView separator = (TextView)divider.findViewById(R.id.separator);
separator.setText(((String)items.get(position).get("name")));
return divider;
} else {
return super.getView(position, convertView, parent);
}
}
What might be my problem?