I’ve some database that i update with a service, and i want to update my listView on resume, or refresh it from time to time with the new data in it, but it’s not working.
Here is my code (the code in comment is not working and sometimes make the app crash)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
taskLiteApplication = ((TaskLiteApplication)getApplicationContext());
listGroupTask = taskLiteApplication.getCtrlGroupTask().getListGroupTaskToDoAndToReview(taskLiteApplication.getUser());
Log.d(TAG, "nbtask to do an to review from DB :"+listGroupTask.size());
if(listGroupTask.size() > 0) {
setContentView(R.layout.to_do_layout);
ListView lv = (ListView) findViewById(R.id.ListViewGroupTaskToDoToDo);
//set adapter
groupTaskToDoBaseAdapter = new GroupTaskToDoBaseAdapter(this, listGroupTask);
lv.setAdapter(groupTaskToDoBaseAdapter);
} else {
TextView textView = new TextView(this);
textView.setText("No tasks to do found!");
setContentView(textView);
}
}
public void onResume() {
super.onResume();
//listGroupTask = taskLiteApplication.getCtrlGroupTask().getListGroupTaskToDoAndToReview(taskLiteApplication.getUser());
//groupTaskToDoBaseAdapter.notifyDataSetChanged();
Log.d(TAG, "on resume");
}
What exactly are your trying here:
Do you want a completely new set of data for your ListView. If so then implement some methods in your Adapter like add/remove/delete/replaceData and so on and after that call the