Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified
Accepted Solution

How to clear ListField component

I have a custom ListField component which is rather simple - the main functionality is in it's paint method. It uses ListFieldCallback callBack = this.getCallback(); to get data. But I have a problem with clearing this table? the list (instance of this class) doesn't have any clear/clean/empty methods, what is the best way to clear it?
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to clear ListField component

Not sure I understand this question. 

 

If you are you trying to clear out all the data so that no rows are displayed, you can use setSize(0);

 

If you want to clear out specific rows that might be displayed, the best thing to do in my opinion is delete the ListField from the Manager and add a new one. 

 

You can invalidate rows in the ListField, but I don't know enough about your requirement to understand if this  would work for you.

 

We commonly do the delete/add process when the data behind the ListField changes - one of the great things about this control this seems to be a very quick process.

Please use plain text.
New Developer
mico
Posts: 20
Registered: ‎04-11-2009
My Device: Not Specified

Re: How to clear ListField component

Thanks, Peter

 

list.setSize(0) did the job. What is not clear for me is why the following code didn't work properly like setSize(0):

 

 

for (int i=0; i<list.getSize(); i++){ list.delete(i);}

 

 

 

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to clear ListField component

I don't use this mecahnism, so I'm not sure about your code, but if you didn't do a list.insert(..), then I suspect that is why the list.delete(.) didn't work as you would have expected
Please use plain text.
New Developer
cypher109
Posts: 5
Registered: ‎12-02-2009
My Device: Javelin 8900

Re: How to clear ListField component

It seems as if it has something to do with the list.getSize() value changing on every iteration because of the delete(i).

Please use plain text.