107 views
in GUI Development by

Hello, i'm implemeting a vertical list to display items from an array.

I want a list of receipts, every receipt has it's own properties like : receipt name, settings etc...

In the init method of the screen where the vertical list is i set the name of the array entries to a default value (1,2,3....)

// TO DO: Write your code here ... 
var int32 i = 0;

for(i=0  ; i< Application::GlobalSettings.ReceiptArray.size ; i=i+1)
{
      
          Application::GlobalSettings.ReceiptArray[i].NomeRicetta = string (i);
}

When Scrolling, the value set by the init method changes to the default value of the item class ( wich is an "#"_), when the disappear and get reloaded.

Initially looks fine

Scrolling down after the 8th item it gets like this:

Then when scrolling Back to top 1st and 2nd item get default.

 

Then scrolling back and forth they get all to the default value of the item class.

This is the onLoadItem method:

/*

  Hint:

  - The code below demonstrates a simple usage of the list component.

  - The list component creates and manages automatically view item instances of
    the class specified in its property 'ItemClass'. In this example it is the
    class 'Views::Text'.

  - When you change the 'ItemClass' property you will also need to replace
    accordingly all 'Views::Text' occurrences in the below code.

  - You will also need to adapt the initialization of the 'itemView'.

*/

// Get the number of the item to load. The list component takes care of the
// creation of the corresponding item view. Just access it ...
var int32       itemNo   = VerticalList.Item;
var Application::ReceiptProgram itemView = (Application::ReceiptProgram)VerticalList.View;

// The implementation of this slot method does not match the item class
// specified in the associated list component. Or the slot method is not
// called in context of the OnLoadItem list operation. 
if ( itemView == null )
  return;

// Configure the item view ...
itemView.NomeRicetta = "Prog. " + Application::GlobalSettings.ReceiptArray[itemNo].NomeRicetta;

// Ensure that the item has correct size. The position of the item will be
// managed by the list component.
itemView.Bounds.size = VerticalList.ViewSize;

 

 

1 Answer

0 votes
by
 
Best answer

Hi Riccardo,

I assume that Application::GlobalSettings is removed by the Garbage Collector and created once more when you access it within your onLoadItem() method.

Please consider the livetime of autoobjects. Everytime, the autoobject is no more in use, the instance will be deleted by the Garbage Collector. Within the Prototyper on PC, the Garabage Collector is running after a couple of seconds - this explains, why you get sometimes the expected value and why the content is lost after some seconds. 

In order to prevent the Garbage Collector from freeing an autoobject, please add a variable to the root class, set the type to your class Application::GlobalSettings and the value to the instance (autoobject) of the class. 

I hope this helps....

Best regards,

Manfred.

by
Yes, perfetc.

Thanks.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...