我有一个代码,我将所有 TODO 添加到适配器,就像这样
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_todo);
adapter = new TODOAdapter(this, TODO.listAll(TODO.class));
listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
}
添加新的 TODO 时,我会这样做
private void createTodo(String s) {
TODOWorker.createTodo(s);
adapter.notifyDataSetChanged();
Toast.makeText(getApplicationContext(), "Your TODO was saved!", Toast.LENGTH_LONG).show();
}
但我的列表视图没有更新......我错过了什么?