2011-08-28 60 views
0

我正在使用它来测试日期是否等于今天的日期。我的项目是从HTML解析一个如何计算多少个项目等于今天的日子?

while(postIt.hasNext) 

它一直继续,直到没有剩下。

if(itemDate.contains(todaysDay)){ 
    System.out.println(i); 
    nm = (NotificationManager) this. 
      getSystemService(Context.NOTIFICATION_SERVICE); 
    CharSequence from = "App"; 
    CharSequence message = nameItem3 + "Today is the day!"; 
    PendingIntent contentIntent = PendingIntent.getActivity(
      this, 0, new Intent(this, HtmlparserExample.class), 0); 
    Notification notif = new Notification(R.drawable.icon, 
      nameOfItem + "Today is the day!!", System.currentTimeMillis()); 
    notif.setLatestEventInfo(this, from, message, contentIntent); 
    nm.notify(1, notif); 
    } 

我想要做的是测试是否有多个项目等于今天的日期。 如果是这样,我想要做的事情,如果是这样。

我该如何去跟踪今天的项目有多少?

我想要发生的事情是,当物品被检索到时,如果超过1个物品等于今天,它会显示不同的通知。

现在发生的事情是,它正在为每个与今天的日期相同的每个项目显示一个通知。

或者其他的工作是我可以显示每个通知?我怎么能这样做呢?

VS.它覆盖每一个,并显示一个新的?

回答

1

将满足您的测试的itemDate实例存储在一个数组中,并根据数组的内容在while循环之外通知用户。

编辑

ArrayList<ItemDate> itemDates = new ArrayList<ItemDate>(); 
while(postIt.hasNext){ 
    /* Do stuff */ 
    if(itemDate.contains(todaysDay)){ 
     itemDates.add(itemDate); 
     /* Do stuff, not notifying */ 
    } 
} 

/* Notify using instances in itemDates */ 
+0

你能提供你的意思代码的例子吗? – yoshi24

+0

你能否提供一些指导你的意思的代码? – yoshi24

+0

添加示例.. – nhaarman

相关问题