Blackberry return to the previus position in ListField

349 views Asked by At

In my application I'm using a list. This list can be updated by a refresh list button which is retriving more data from serever. When user pressing the refresh button, my application seves the last selected item into a memeber field -

lastPosition = listField.getSelectedIndex();

After updating the list, my application uses -

listField.setSelectedIndex(lastPosition);

for setting the last position. But nothing happen.

How can i "move" the list's cursor to point on the lastPosition? Thanks, Eyal.

                listField.setKeyword("");
            listField.v = userVector;               
            listField.updateList(); 
            listField.getResultList();
            listField.setSelectedIndex(lastPosition);
            listField.setFocus();
            Manager manager = listField.getManager();
            int rowHeight = listField.getRowHeight();
            manager.setVerticalScroll(lastPosition * rowHeight);
            listField.invalidate();
1

There are 1 answers

5
Vit Khudenko On BEST ANSWER

It's hard to guess what is wrong without seeing the code, however the first thing that comes to mind is probably you don't set focus on the list right after you restore the position? If you don't, then try it:

listField.setSelectedIndex(lastPosition);
listField.setFocus();