目前我做到以下几点:如何在数据库值更改的情况下更新ListView?
1)数据库链接到ListView控件:
String[] from = new String[]{DbAdapter.KEY_TITLE,
DbAdapter.KEY_DISPLAYED_VALUE,
DbAdapter.KEY_FAVORITE};
int[] to = new int[]{R.id.name, R.id.time, R.id.icon};
items = new SimpleCursorAdapter(this, R.layout.row, itemsCursor, from, to);
2)KEY_DISPLAYED_VALUE
在数据库中每2秒改变。然后调用items.notifyDataSetChanged()
。但屏幕上的数据没有更新(R.id.time
目前为TextView
,一旦此代码有效,将为TextSwitcher
)。
数据库更新为execSQL。