如何管理Android的活动? [英] How to manage activities in Android?
问题描述
我在改变使用标签一项活动中发现的问题。在一个选项卡活动,我将数据添加到我的SQLite数据库,并在其他选项卡活动,我使用的ListView(阵列适配器)显示它们。但是,当我回来的时候添加新项目的SQLite后添加数据,不更新列表视图我的新添加的记录。
I identified a problem in changing one activity using tab. In one tab activity I'm adding data to my SQLite database, and in the other tab activity I am displaying them using listview(array adapter). But when I come back to add data after adding new items to SQLite, the newly added records are not updated in my listview.
我该如何解决这个问题?
How do I fix this?
推荐答案
您似乎是从DB拉列表中的数据。是否有一个原因,您使用的是ArrayAdapter而不是CursorAdapter的呢?
You seem to be pulling the list data from a DB. Is there a reason why you are using an ArrayAdapter instead of a CursorAdapter?
无论如何,你应该叫<一个href=\"http://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged%28%29\"相对=nofollow> notifyDataSetChanged()在您的列表适配器当数据发生了变化,因此它可以刷新视图。
Anyway, you should call notifyDataSetChanged() on your list adapter when the data has changed so it can refresh the view.
这篇关于如何管理Android的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!