10-09-2008 07:26 PM
To answer your question:
a) except ListField(0,...) gives me exception.
//myList = new ListField()//ListField(QueryResultScreen.search_no
//myList = new ListField(2, ListField.FIELD_HCENTER|ListField.USE_ALL_WIDTH) -->throw exception.
b) I passed 2 elements in the list and throw the exception, I tried 1 also with one element, it was same. only works for 0. Don't know.
c) the only reason is that the designer design the screen to be centered with left and right padding so that's why I'm using it and I copied from example.
So now to me ListFied (0,...) is working but just I wanted to let you that strange thing happened to me.
10-09-2008 08:48 PM - edited 10-09-2008 08:50 PM
a) So the statement that throws the exception is:
myList = new ListField(2, ListField.FIELD_HCENTER|ListField.USE_ALL_WIDTH)
Since this statement has nothing to do with arrays, I presume that the stack trace, or the line that it dies on in the debugger, is somewhere else - can you tell us where?
b) How did you pass the elements to the List. Remember that by setting the count to 2, you are saying that there are already 2 elements in the list. So your ListFieldCallback object should be able to supply Objects when called with index of 0 and index of 1 immediately. I note the 'insert's that you do. If you do one of these, and the ListField already thinks you have 2 elements (since you told it two in the Constructor), then after your first insert, the ListField will think there are three elements and after the second it will think there are 4 and so on...
c) I see that this code is from the following KB article:
How To - Create a color ListField
Article Number: DB-00472
I don't like this approach, but that is just personal preference.
I see that you have also used this KB article to set the width:
How To - Create a custom width for a ListField
Article Number: DB-0011
I'm concerned that there is bug here, but I'm wondering if the problem is just because you have told the ListField that there are two rows initially, but then your ListFieldCallback get() routine only knows about the ones that you have inserted, meaning it is short of 2 entries.