我正在嘗試使用「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