Hello,
i managed to update my list items by using a data storage array and Number of items control method and device integration works very well. now all i need is the blinking ability for new alarms added to my array which is presented on the list until an acknowledgment. i can use a button to simulate it for the time being but cant make it work on individual items of the list.
In this case I would do following:
Step 1: The blinking is in this case is an individual state associated to each item. Consequently, you have to manage this state in the the data storage. For example, new alarms within the data storage have the blinking state enabled.
Step 2: From your screenshot I see you have a timer in the GUI component containing the 4 lists. This is the timer used for blinking, right? In this case I would do following:
a.) Add a bool variable to track the blinking state. Name it e.g. BlinkPhase.
b.) Each time the timer expires (the Slot method is invoked), you toggle the value in the variable BlinkPhase.
c.) Each time the timer expires you also force the list containing the alarms to reload its items.
The implementation of the Slot method would look like this:
// Toggle the blink state
BlinkPhase = !BlinkPhase;
// Trigger the list to reload its content
AlarmList.InvalidateItems( 0, AlarmList.NoOfItems - 1 );
d.) In the OnLoadItem method corresponding to the alarm list, check in the data storage the blink state of the respective item. If the item should blink, determine the color of the item according to the BlinkPhase variable. If the item should not blink, you can select other color. For example:
if ( YourDataStorage.IsAlarmActiveForItem( itemNo ))
{
if ( BlinkPhase )
itemView.Color = SomeColorForTheBlinkPhaseOn;
else
itemView.Color = SomeColorForTheBlinkPhaseOff;
}
else
itemView.Color = SomeColorIfTheItemIsNotBlinking;
ALTERNATIVE APPROACH:
In the above example, I assumed the list uses ordinary Text views as items. Another, more sophisticated approach would be to implement a dedicated GUI component for the single item. (Most of the examples in the chapter Vertical List implement such item classes). With this approach you can move the blinking into the item. In other words, instead of the 'global' blink timer each item will have its own timer to blink.
To control the blinking you should then add a bool property to the item class. Name the property e.g. BlinkState. In the onset method of the BlinkState property you enable/disable the locally used timer according to the value just assigned to the property. The timer, in turn, toggles some colors or visible states of views existing in the item.
The 'global' timer is not needed anymore. The OnLoadItem method limits to update the item's BlinkState property according to the corresponding data from data storage. When the user presses the button to clear the alarms, your implementation resets the alarms in the data storage and forces the list to reload its contents again. Accordingly, the BlinkState property of the affected items is updated and the items stop blinking.
What i need is, if the date and time on 3rd list item is present, the number 25 on the 4th list needs to be white colored.
the number 33 and 17 needs to be Yellow because they dont have any date and time related to them in list 3 but in List 2
and number 16 and 1 needs to be Red because they only have date and time at same line as themselves in List 1
The coloring of an item is not a problem. From my preceding answer and in the above code sample you can see how to set the color individually for an item. The problem you have to solve here is more related to the data storage. How should the 4th list deduce that item N is red, green or yellow? Possibly you have to enhance your data storage to manage this information. Or you can derive the color from the state found in other lists?
Once you found the way to estimate the color for each item in the 4th list, you adapt the OnLoadItem4 method and use this information. For example:
itemView.Color = YourDataStorage.GetColorForItem( itemNo );
Since the colors in the 4th list seem to depend on the contents from the other lists, you have to force the 4th list to reload its contents each time the items in other lists change. In such case you execute the code:
List4.InvalidateItems( 0, List4.NoOfItems - 1 );
I hope, the explanation helps you a little bit further.
Best regards
Paul Banach