【发布时间】:2014-06-26 05:57:53
【问题描述】:
我有 3 个包含带有自定义适配器的列表视图的活动,在第一个选择的项目将用户驱动到第二个,依此类推...
在这些列表视图中,一些项目被突出显示为“新项目”(每次调用适配器的 getView 时,我都会检查数据库是否应该突出显示当前项目)。一旦用户到达第三个列表视图,我将这些项目标记为“已选中”,并希望将此更改传播回其他列表视图...
这意味着,当用户返回时,从堆栈中拉出第二个和第一个列表视图,我希望不再突出显示查看的项目。
我试过this answer on SO,但没有成功。从 onResume() 执行 notifyDataSetChanged() 时,我的列表视图根本没有出现。而且我不想使用 startActivityforResult()...
这是我在 onResume() 处刷新列表视图的代码:
@Override
public void onResume(){
super.onResume();
//I have basically the same code at onCreate()
adapter = new ListingsAdapter(getApplicationContext(), this);
list.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
这里的another answer 听起来很有希望,但我不确定如何从适配器中检索特定视图...我想使用 adapter.getView() 检查所有可见项目,但它要求一个 convertView和一个父 ViewGroup,我无法得到它
提前感谢您对此的任何提示
【问题讨论】:
标签: android listview android-listview