我想每天从xml列出listview中的一些项目。为此,我在我的项目中创建了<date>27.11.2015</date>
标签,我正在使用xmlpullparser。但它通常会显示列表中的所有项目。如何才能获得当前日期和#39; s项目?
XML
<resources>
<food>
<date>28.10.2015</date>
<img>http://.....png</img>
<name>taze fasülye</name>
<calories>488 Kalori</calories>
</food>
<food>
<date>28.11.2015</date>
<img>http....png</img>
<name>bamya</name>
<calories>110 Kalori</calories>
</food>
<food>
<date>29.11.2015</date>
<img>http://...png</img>
<name>kıyma</name>
<calories>682 Kalori</calories>
</food>
PullParser.java
while (eventType != XmlPullParser.END_DOCUMENT) {
String tagname = xpp.getName();
switch (eventType) {
case XmlPullParser.START_TAG:
if (tagname.equalsIgnoreCase("food")) {
curFood = new FoodItem();
}
break;
case XmlPullParser.TEXT:
curText = xpp.getText();
break;
case XmlPullParser.END_TAG:
if (tagname.equalsIgnoreCase("food")) {
foods.add(curFood);
} else if (tagname.equalsIgnoreCase("name")) {
curFood.setName(curText);
} else if (tagname.equalsIgnoreCase("date")) {
curFood.setDate(curText);
} else if (tagname.equalsIgnoreCase("img")) {
curFood.setImgUrl(curText);
}
else if (tagname.equalsIgnoreCase("calories")) {
curFood.setCalories(curText);
}
break;
default:
break;
}
eventType = xpp.next();
我希望它只显示今天的食物。这可能吗? Also I created currentDate same as type of my date