This question is the same as my another question http://stackoverflow.com/questions/3648840/listview-with-section-header-problem
When scrolling the ListView, some header text will appear, below are the related code for easier understanding:
records.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor,int columnIndex) {
if (columnIndex == dateIndex) {
//get the record date
dateString = cursor.getString(columnIndex);
//first record or different date records show date title
if(titleSet.equals(dateString) ||!prevDate.equals(dateString) ){
((TextView) view).setText(dateString);
view.setVisibility(View.VISIBLE);
prevDate = dateString;
}else {
//same day record not show title
((TextView) view).setText("");
view.setVisibility(View.GONE);
}
return true;
}
The problem lies on prevDate = dateString. While scrolling, the dateString will change so that preDate will not be accurate as well. So is there anyway I can fix dateString after ListView created? Or to prevent the dateString change out of order? Thanks!