小编spr*_*yan的帖子

android:使用ListAdapter和SimpleCursorAdapter刷新ListView

我正在尝试刷新使用创建为SimpleCursorAdapter的ListAdapter的ListView.

这是我在onCreate中创建Cursor和ListAdapter的代码,它填充了ListView.

tCursor = db.getAllEntries();       

ListAdapter adapter=new SimpleCursorAdapter(this,
                R.layout.row, tCursor,
                new String[] columns,
                new int[] {R.id.rowid, R.id.date});

setListAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

然后,我在另一个方法中向db添加一些数据,但我无法弄清楚如何刷新ListView.stackoverflow和其他地方的类似问题提到使用notifyDataSetChanged()和requery(),但ListAdapter或SimpleCursorAdapter的方法都没有.

android listview refresh listadapter simplecursoradapter

3
推荐指数
1
解决办法
1万
查看次数