我需要实现 CursorAdapter
,我需要一次过滤掉某些行。
例如:首先显示 1-5,然后显示 5-10。
我已经按照它管理了 getCount()
,但是仅仅通过改变光标位置它是行不通的。
我需要知道这些行如何获得位置,或者如何推进在 newView()
和 bindView()
中作为参数提供的光标。
P.S: 我知道 limit
和 paging
和 offset
,但不想每次都获取查询
最佳答案
嘿,在你的适配器中覆盖这些方法,如下所示。您可以通过更改 presentPage 并通知 adpater 来更改页面
int numOfItemsPerPage=5,presentPage=0;
public int getCount() {
return (list.size()>= numOfItemsPerPage) ?list.size():numOfItemsPerPage;
}
public Object getItem(int position) {
if(list.size()>= numOfItemsPerPage)
{
position= (numOfItemsPerPage * presentPage)+position;
}
return list.get(position);
}
关于android更改游标适配器中的游标位置以增加或减少行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9239066/