嗨im显示一个ListView与SimpleCursorAdapter
和alternat ListItem
样式,我想要动态更新列表,如果用户在视图和更新发生。在我的ListActivity我在我的适配器从SimpleCursorAdapter
延伸做动态更新ListView与扩展SimpleCursorAdapter和替代LiteItem样式
adapter.swapCursor(newCursor);
//notify
我有两个重载方法
@Override
public int getViewTypeCount() {
return 2;
}
和
@Override
public int getItemViewType(int position) {
adapCursor.moveToPosition(position);//adapCursor is being set in the constructor
int i= adapCursor.getInt(adapterCursor.getColumnIndexOrThrow("isactive"));
return i==1?i:0;
}
现在的问题是,当我更新适配器更新的游标在getItemViewType
方法中不可用,因此会抛出索引超出范围的异常...
我怎样才能获得更新的光标,还是回到正确ItemViewType
问候
或者你可以使用'getCursor()'而不是你的参考。 – Luksprog
@Luksprog更清洁的方式,我不必调用'super.swapCursor'把它放在答案中,我会接受它... tnx的信息 – dakait