blackberry - Number of Events in EventList -
i need find number of events stored in eventlist events extracted calendar.
there no size()
method found.
below code
eventlist eventlist = (eventlist)pim.getinstance().openpimlist( pim.event_list, pim.read_write); enumeration eventslist = eventlist.items(eventlist.starting, startdateevent, enddateevent, false);
how can find number of events in eventslist enumeration?
unfortunately, if want number of events between start , end dates, you'll need count them. enumeration
doesn't provide interface getting number of elements.
eventlist eventlist = (eventlist)pim.getinstance().openpimlist( pim.event_list, pim.read_write); enumeration eventslist = eventlist.items(eventlist.starting, startdateevent, enddateevent, false); int numevents = 0; while (eventslist.hasmoreelements()) { eventslist.nextelement(); numevents++; } system.out.println("there " + numevents + " events in list");
if still want iterate on list after counting, you'll need new enumeration
object calling eventlist.items()
again.
if, however, want number of events in entire eventlist
, can size casting full list blackberryeventlist
:
from the blackberry api docs:
any instance of eventlist retrieved pim.openpimlist() when specified pimlisttype==pim.event_list instance of blackberryeventlist , can casted blackberryeventlist, if desired, in order use rim extension functionality.
so, should cast list blackberryeventlist
(or blackberrypimlist
), , can this:
eventlist eventlist = (eventlist)pim.getinstance().openpimlist( pim.event_list, pim.read_write); if (eventlist instanceof blackberryeventlist) { // should succeed blackberryeventlist bbeventlist = (blackberryeventlist)eventlist; int sizeoflist = bbeventlist.size(); }
Comments
Post a Comment