我是android和java的新手。我正在做一个解析XML并在不同页面中显示内容的活动(分页)。在解析时,我检查是否已经有多达5个元素(页面上的元素数量),并调用更新函数(代码如下所示)。理想情况下,一旦解析器解析了5个元素,我就应该在屏幕上获得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 = "";
}
}
}