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
Contributor
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr
Accepted Solution

listfield issue removing the last element

Hi all !

 

Is there a known issue in ListField that explains the raise of an OutOfboundException while removing an element of a list with only one element ?

 

When using listField.delete() I get this exception when the screen is trying to set the focus.

New Contributor
Posts: 9
Registered: ‎04-26-2011
My Device: Developer
My Carrier: Cell One

Re: listfield issue removing the last element

There may be the case that the screen does not contain any other focusable field. Hence exception is coming.

You can try

_listView.setEmptyString("List is Empty", DrawStyle.HCENTER);

which is focusable and wont give any exception after deleting last element.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: listfield issue removing the last element

Agree with the previous poster's suggestions.  One other trick I have used in this circumstance is actually to make the ListField non focusable when it has no elements, by overriding

isFocusable() and returning false when it has no contents. 

 

That said, this sounds like a bug to me, is it reproducible in a small piece of sample code?

Highlighted
Contributor
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr

Re: listfield issue removing the last element

Thank you for your answer. I finally resolved the issue in my case using the "isFocusable-overriding" solution you are describing here.

Then as the default empty string is not the best solution for me to display information when the list does not contain any element, I implement my own logic with a specific customized LabelField displayed instead of the ListField.

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: listfield issue removing the last element

Very good.

 

Can you mark this as solved then?  If you don't know how, the Help (link near top) should. well, help....