i m working with Listfield in os 5.0 and letter.my all data comes from webservice and display it in listfield .. everything work fine at first time during parsing time and display in listfield successfully .. if at the first time i have only one record to display in row it work fine but i click on my NextButtonfield to update listfield , i get more than one record and listfield show me one one record ..
i have debug alot and get some issue .. index of drawListRow method not incremented as setSize(listItem.size()); . listItem is vector and it update successfully depend on record .
so how to update index depend on vector size ? or how to remove all row at update time ?
Some hints that will help save you a lot of headache when working with data in a
ListFieldthat could potentially change:Vectorin this case) to house data that with both be updated and used by theListField, make sure that you synchronize whatever chunk of code is updating thatVector. If you don't, you're likely to run into an IndexOutOfBounds Exception because theListFielddoesn't know how big theVectoris while it's being updated.setItems()call in yourListFieldthat will go through the Vector and just store a name (or whatever it is that you're displaying) and update the size so that no matter what you do to your Vector, theListFieldwill always have good data.In your case, you are correct in that you need to be calling the
setSize(listItem.size());to update the number of items in the list. If you use my second suggestion, what you could do to remove everything is simply calllist.setItems(new Vector());and that would set the size to 0 and also clear out the stored items. Alternatively, simply callinglist.setSize(0);will emulate the list being empty because it won't think it has anything to draw, so your "empty string" will be shown instead.It could also be that there is a problem with your
drawListRow()method so it doesn't look like anything more than one row is being shown. If you post the code from it we can take a look at it and let you know if there are any potential problems.