【发布时间】:2014-06-26 07:07:16
【问题描述】:
我有一个ListFragment,其数据由自定义适配器填充(在我的情况下为SimpleAdapter)。我在扩展ListFragment 的班级中使用notifyDataSetChanged() 时遇到问题。经过大量的环顾和几篇(有用的)Stack Overflow 帖子之后:
listview not updating with notifydatasetchanged() call
Android ListView not refreshing after notifyDataSetChanged
adapters notifyDataSetChanged does not work
notifyDataSetChanged not working
ListView does not update when calling notifyDataSetChanged from a BaseAdapter
我知道一个松散的(并且非常不推荐的)解决方法是使用setListAdapter() 重新设置您的适配器。但是,我现在也面临着这个问题。
文档http://developer.android.com/reference/android/app/ListFragment.html#setListAdapter(android.widget.ListAdapter) 提到setListAdapter()
为列表视图提供光标。
但我还有一些问题。
第一季度。使用 setListAdapter() 'point' 多次初始化适配器是否指向同一个适配器实例?
第二季度。当使用 setListAdapter() 多次设置适配器时,调用 getListAdapter() 然后调用 notifyDataSetChanged() 实际会发生什么?
第三季度。这个问题基于 Q2 的假设——当多次设置适配器时调用 notifyDataSetChanged() 时,如果它们存在,哪些适配器实例(这部分是假设)实际上被通知更改?
我是 Android 的初学者,我相信有很多细微差别我不明白。如果您能澄清这些问题,我将不胜感激。也非常感谢您抽出宝贵的时间。
【问题讨论】:
标签: android android-listview android-adapter