我正在尝试使用“http://github.com/commonsguy/cwac-endless”为我的列表视图实现分页。Android:无尽的适配器问题
当我向下滚动到第一页的底部时,我正确地获得第一页结果,我看到了旋转轮,但没有得到任何结果。
我注意到从LogCat中,getPendingView(),cacheInBackground(),appendCachedData()和MyCustomAdapter的getView()被无限调用。
任何人都可以帮忙。
谢谢, nehatha。
这里是我的代码片段:
Activity{
onCreate() {
myList = new ArrayList<Item>();
setListAdapter(new DemoAdapter(myList));
nextLink = "service_url"; //for first page results (say 1-25)
}
final Handler handler = new Handler() {
public void handleMessage(final Message msg) {
//
updateList(jsonResponse);
}
};
updateList(String jsonString) {
//parse json
//add to `myList`
//update `nextLink`, if there is next page available
}
class DemoAdapter extends EndlessAdapter {
private RotateAnimation rotate=null;
DemoAdapter(List<Item> list) {
super(new MyCustomAdapter(LatestUpdatesList.this, R.layout.latest_update_item, list));
//rotate code
}
@Override
protected boolean cacheInBackground() {
if(nextLink != null && nextLink.length() > 0){
HttpHandler httpHandler = new HttpHandler(nextLink, "GET", handler);
Thread latestUpdatesThread = new Thread(httpHandler);
latestUpdatesThread.start();
return true;
}
return false;
}
@Override
protected void appendCachedData() {
MyCustomAdapter adapter = (MyCustomAdapter)getWrappedAdapter();
adapter.setList(myList);
}
} //DemoAdapter
} //Activitiy
能否请你帮我在这EndlessAdapter为您的代码看起来类似于我的要求? – Korhan 2013-02-13 10:45:46