繁体   English   中英

如何一一数数等于今天的物品?

[英]How to count how many items equals Todays Day one by one?

我正在用它来测试日期是否等于当天的日期。 我的项目是从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);
  }

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

我将如何跟踪今天有多少物品?

我想发生的是,当退回物品时,如果今天有超过一件物品经过测试,它们会显示不同的通知。

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

或者其他可行的方法是我可以为每个人显示通知吗? 我也该怎么办?

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

将满足测试条件的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 */

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM