Search code examples
blackberryblackberry-eclipse-pluginblackberry-jde

How can use same listfield for displaying elements,and new elements will getwhenuser click on existing listfield elements


In my app, I displaying a ListField with indefinte no of elements(the elements gets from json returned by a webserver).

First the app displays some elements(item 1,item2,..),and user click in one of them.The same listField object reloaded with some new elements.

Since there is variable no of elements switch-case in navigationClick willn't work.If any one have idea please help.


Solution

  • The magic of list field lies on the vector or array of object you use to represent each row. <p.s. I expect you to understand this and you have pretty good hands on experience on drawListRow() method>

    Suppose you have list for level 1. You show a Title(string) and a subtitle(string). And on click of each item you have a list that renders same data (again title and subtitle) and for n levels the rendering will be same.

    If this is the situation you can do one thing, change the collection of your list everytime. i.e. if you use an array, change the contents of array. If you use Vector change the vector.

    If rendering of your list row changes than you have two options, 1. You can handle it with flags in same drawListRow() method

    OR

    1. You have to write a new class and a new drawListRow() method

    Hope it helps.