What im trying to do is change the value of 1 edittext in each listItem. i.e the DueDate is coming from database as a dateString 01/01/2016 and i want to change it to how many days are between now and then instead when it appears in the listView.
I need to get the value its set to now and send it through a method to calculate the days between now and then which is easy enough but the problem is when using a cursorAdapter theres no loop that i can edit the edittext.
getValues Method which fills the list
final String[] from = new String[]{"_id", "ProjectSubject", "ProjectTitle", "ProjectWorth", "ProjectDueDate", "ProjectDetails"};
final int[] to = new int[]{R.id.IdText, R.id.SubjectTextList, R.id.ProjectTitleTextList, R.id.WorthText, R.id.DueDateTextList, R.id.DetailsTextList};
Cursor cursor = dbHelper.fetchAllProjects();
dataAdapter = new SimpleCursorAdapter(context, R.layout.summary_list_item,cursor,from, to, 0);
list.setAdapter(dataAdapter);
Adapter method which fetches the projects
public Cursor fetchAllProjects() {
Cursor mCursor = mDb.query(SQLITE_TABLE, new String[]{
KEY_ID,
KEY_SUBJECT,
KEY_TYPE,
KEY_TITLE,
KEY_WORTH,
KEY_DUEDATE,
KEY_DETAILS,
KEY_EMAIL},
null, null, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
Edit -
dataAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (columnIndex == 5) {
((TextView) dueDateText).setText(cursor.getString(columnIndex) + " modified");
return true;
} else {
return false;
}
}
});