1
我是新來的android和java。我正在做一個解析XML並在不同頁面顯示內容的活動(分頁)。在解析時,我檢查是否已有多達5個元素(頁面上的元素數量),並調用更新函數(如下所示的代碼)。理想情況下,只要解析器解析5個元素,我應該在我的屏幕上獲得listview,這不會發生。幫幫我!!!無法使用Observer模式實現更新ListView
public class FeedActivity extends Activity
implements OnGestureListener, OnTouchListener, FeedDataListener {
......
private void doit() {
...
feedAdapter = new FeedListAdapter(this, R.layout.pagination1,
feedListPage.getFeedList());
lv.setAdapter(feedAdapter);
...
}
public void update(FeedItemList fil, int page) {
if (feedList == null) {
feedList = fil;
doit();
}
else {
feedList.getFeedList().clear();
feedList.setFeedList(fil.getFeedList());
feedAdapter.notifyDataSetChanged();
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (localName.equalsIgnoreCase("item")) {
if (fi != null) flist.addFeedItem(fi);
if (flist.getSize() % 5 == 0)
l.update(flist,
(int) Math.ceil((float) flist.getSize()/(float) 2));
} else if (fi != null) {
if (itemSubElements.contains(localName)) {
fi.setElement(_tmpItem, html2text(_tmpValue));
_tmpItem = null;
_tmpValue = "";
}
}
}
網站已經死了。回頭機器網址:http://web.archive.org/web/20120606182235/http://androidworkz.com/2010/08/13/smart-list-adapter-tutorial-singleton-oberservable-list-objects-and - 如何,他們可任意提高,你的應用程序內 – 2013-11-20 21:45:31