I have a simple problem that I'm sorry to ask this, but I'm looking for a solution for hours Now I can not stand it.
My app is very easy. I've got "Working in a SQLite DB", and I populate with the DB to the list:
_dataAdapter = new function adapters (_c, _taskDAO.getTasks ()); _listTask.setAdapter (_dataAdapter); gives an array of work list.
The problem is, when I click on the dialog to delete the task, it removes it from DB, but it is still on the screen, so I need to refresh the list view.
issue DialogInterface.BUTTON_NEUTRAL: _taskDAO.removeTask (1); _dataAdapter.notifyDataSetChanged (); break; But this does not work, I think it is due to the fact that I am removing the work from DB but not with the adapter, but I am not completely sure. Anyway, if someone has a solution ...
If your adapter is an arrayaddetter or base adapter , The data is the source of your ListView, not just DB but the list you provide to the adapter.
You will need to update your adapter's datasheet (give it a new list) then call
_dataAdapter.notifyDataSetChanged (); Another solution would be to recreate the adapter:
_dataAdapter = null; _dataAdapter = New task adapter (_c, _taskDAO.getTasks ()); _listTask.setAdapter (_dataAdapter); Hope it helps
No comments:
Post a Comment